Basic HTML version of Foils prepared 3 March 99

Foil 67 Simple Regular Expression Patterns

From Overview of JavaScript I -- Basic Web Scripting Language CPS616 Technologies of the Information Age -- Spring Semester 99. by Geoffrey C. Fox (Tom Scavo)


Simple Single-character Patterns are :
  • Single explicit character e.g. a
  • dot . which matches ANY character except newline \n
Character class is a Single-character Pattern and represented as a set [c1c2c3...cN] which matches any one of the listed characters
  • [ABCDE] matches A B C D or E
  • [0-9] is same as [0123456789]
  • [a-zA-Z] matches any lower or upper case letter
Negated character class is represented by a carat ^ after left [ square bracket
  • [^0-9] matches any character which is NOT a digit 0 1 2 3 4 5 6 7 8 9 (there is another critical use of ^ -- see later)
There are a set of special character classes shown overleaf such as \w which is equivalent to [A-Za-z0-9_].



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Wed Mar 3 1999