regexp = /(\/|\*|\+|-)/ regexp = /.+(\/|\*|\+|-).+/ regexp = /\d|\./ regexp = /^[^\/\*\+].+\d$/ regexp = /\./ . # Any single character except a newline ^ # The beginning of the line or string $ # The end of the line or string * # Zero or more of the last character + # One or more of the last character ? # Zero or one of the last character ----------------------------------------------------------------------------- t.e # t followed by anthing followed by e # This will match the # tre # tle # but not te # tale ^f # f at the beginning of a line^ftp # ftp at the beginning of a line e$ # e at the end of a linetle$ # tle at the end of a line und* # un followed by zero or more d characters # This will match un # und # undd # unddd (etc) .* # Any string without a newline. This is because the . matches # anything except a newline and # the * means zero or more of these.^$ # A line with nothing in it. ----------------------------------------------------------------------------- [qjk] # Either q or j or k [^qjk] # Neither q nor j nor k [a-z] # Anything from a to z inclusive [^a-z] # No lower case letters [a-zA-Z] # Any letter [a-z]+ # Any non-zero sequence of lower case letters jelly|cream # Either jelly or cream (eg|le)gs # Either eggs or legs (da)+ # Either da or dada or dadada or... ----------------------------------------------------------------------------- \n # A newline \t # A tab \w # Any alphanumeric (word) character. # The same as [a-zA-Z0-9_] \W # Any non-word character. # The same as [^a-zA-Z0-9_] \d # Any digit. The same as [0-9] \D # Any non-digit. The same as [^0-9] \s # Any whitespace character: space, tab, newline, etc \S # Any non-whitespace character \b # A word boundary, outside [] only \B # No word boundary \| # Vertical bar \[ # An open square bracket \) # A closing parenthesis \* # An asterisk \^ # A carat symbol \/ # A slash \\ # A backslash ----------------------------------------------------------------------------- [01] # Either "0" or "1" \/0 # A division by zero: "/0" \/ 0 # A division by zero with a space: "/ 0" \/\s0 # A division by zero with a whitespace: # "/ 0" where the space may be a tab etc. \/ *0 # A division by zero with possibly some # spaces: "/0" or "/ 0" or "/ 0" etc. \/\s*0 # A division by zero with possibly some # whitespace. \/\s*0\.0* # As the previous one, but with decimal # point and maybe some 0s after it. Accepts # "/0." and "/0.0" and "/0.00" etc and # "/ 0." and "/ 0.0" and "/ 0.00" etc. ----------------------------------------------------------------------------- a # match a a* # match zero or more character a's . # match any character .* # match zero or more of . [a-m] # match characters a through m only [^n-z] # do not match letters n to z [a-m]* # match zero or more letters a to m ^ # match the beginning of the line $ # match the end of the line \t # matches a tab character \d # same as [0-9] \D # same as [^0-9] \s # matches white space (space or tab) \S # matches anything but white space \w # same as [0-9a-zA-Z] characters) \W # same as [^0-9a-zA-Z] .+ # same as ..* [a-m]+ # match one or more letters a to m a{n,m} # at least n a's, not more than m a's a? # zero or one a, not more than one \cD # matches control-D ----------------------------------------------------------------------------- string.match(/arg/[switch]) if(string.match(/[0-9]/)) alert('no numbers allowed') string.split(/arg/[switch]) words = string.split(//) sentence = string.split(/ /) sentences = string.split(/\./) abc = 'a::b::c::d' abc = abc.split(/:+/) string.replace(/+/g,' ') form.input.value.replace(/TAB/g,'\t') boolean usage: regexp = /pattern/ regexp = /pattern/switch sentence =~ /the/ returns true if "the" is in the variable string sentence !~ /the/ returns true if "the" is not in the variable string switch: i (ignore case) g (global search for all occurrences of pattern) gi (global search, ignore case) ex: regexp = /pattern/i properties (javascript): regexp.global - boolean value (/'pattern'/g) is true. regexp.ignorecase - boolean value (/'pattern'/i) is true. regexp.lastIndex - specifies the index point from which to begin the next match. regexp.source - contains the text of the regular expression pattern. regexp.compile - compiles a string expression containing a regexp pattern into an internal format. regexp.exec - searches for a match in the specified string. returns object of type null or array. boolean regexp.test - tests whether a pattern exists in a string. returns object of type boolean.