Basic HTML version of Foils prepared 3 March 99

Foil 75 Some Regular Expression Examples

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


/\s0(1+)/ matches "white space", followed by zero and 1 or more ones -- the set of ones is stored in \1 ( $1)
/[0-9]\.0\D/ matches "the answer is 1.0 exactly" but not "The answer is 1.00".
In first case $` is "the answer is ", $& is "1.0 " and $' is "exactly"
/a.*c.*d/ matches "axxxxcxxxxcdxxxxd" with $` and $' as null and $& as full string
/(a.*b)c.*d/ matches "axxxxbcxxxxbd" with
\1 as "axxxxb" -- note backtracking as greedy (a.*b) first matches to "axxxxbcxxxxb" but then tries again when following c.*d fails to match



© 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