JavaScript regular expression notes

 

http://www.w3schools.com/js/js_regexp.asp

*        is a start (but could use more explanation and examples)

*         [l-p] means any letter from l to p

o   I.e., l, m, n, o, or p

o   /[l-p]e/gi  means

*        any letter from l to p

*        followed by an e

*        all the places where it occurs

o   (the g is for global)

*        ignoring whether they are upper or lower case

o   (the i is for: insensitive to case)

 

http://www.javascriptkit.com/javatutors/re.shtml

*        Check the example

*         var re5digit=/^\d{5}$/

o   /    indicates start of a regular expression object

o   ^   matches only the beginning of a string

*  it does not eat up a character

*  matching fails if in the middle of a string

o   \    is an escape character, modifying the next one

o   d   a numeral (digit) character

*  not the letter d. Why not?

o   {    begin specifying a number of repeats

o   5    five \d characters

o   }    end specifying the number of \d characters

o   $    matches only the end of a string

*  it does not eat up a character

*  matching fails if not at the end of a string

o   Try it

o   One could also try some of these features in a w3schools sandbox

*  Not all browsers comply with everything

 

http://www.regular-expressions.info/javascriptexample.html

*        Let’s try the example there

*  and analyze it

o     \b    matches only the beginning or end of a word

o   /b    is the first part of a regular expression

o   What is /b/?

o   What is /\b/?

o   /\bhello\b/gi    does what?  

o   One could try some of these in a sandbox

o   Not all browsers comply with everything

 

http://javascript.info/tutorial/regular-expressions-javascript

This site has lots of information!