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)


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

in Table To:


© 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