| RegExp() The regExp object is used to monitor and generate any instance of a regular expression within the current window or frame. Regular expressions are used to locate text or string matches within the document it is being invoked within. Use this in form data verification, for example - verifying that five digits have been entered for a zip code. Specifying the scope of the regular expression is accomplished through the use of regular expression notation, which is a series of switches used with the string you are searching for. A summary of the most common switches can be found below. Regular Expression Notation b Word Boundary B Non-Word Boundary d Numerals, 0 through to 9 D Non-Numeral g Global Search On i Ignore Capitals (Case) s Single WhiteSpace S Single Non-WhiteSpace w Letter, Numeral, or UnderScore W NOT a Letter, Numeral, or UnderScore . (period) Any Character, except a new line [ ... ] Any of the charater sets in the square brackets [^...] Negated Character Set * Zero or More Times ? Zero or One Time + One or More Times {n} Exactly 'n' Times {n, ] 'n' or More Times {n, m} At Least 'n' Times, and at Most 'm' Times ^ At the Beginning of a String or Line $ At the End of a String or Line You see from the large array of switches available that many things can be accomplished by the invocation of this object. Examine the syntax and examples below to get a feel for how the regExp object is used. syntax: var variableName = new RegExp( "string," [ "comma delimited switches in quotes" ] ) EXAMPLE var searchString = new RegExp ( "big", [ "^", "{8, 10}" ] ) The example is looking for the string 'big' (a word, as is most common), at the beginning of a string or line, at least 8 times but no more than ten times. The Properties of RegExp are: • input • lastMatch • lastParen • leftContext • multipline • rightContext • $1 • $2 • $3 • $4 • $5 • $6 • $7 • $8 • $9 Methods of RegExp are: • No Methods have been defined for this Object |