Skip to main content

Posts

Showing posts from November, 2013

javaScript RegExp Object

Syntax var patt=new RegExp(pattern,modifiers); or more simply: var patt=/pattern/modifiers; pattern specifies the pattern of an expression modifiers specify if a search should be global, case-sensitive, etc. Modifiers Modifiers are used to perform case-insensitive and global searches: Modifier Description i Perform case-insensitive matching g Perform a global match (find all  matches rather than stopping after the first match) m Perform multiline matching Example 1 Do a case-insensitive search for "w3schools" in a string: var str="Visit W3Schools"; var patt1=/w3schools/i; The  marked  text below shows where the expression gets a match: Visit  W3Schools var pattern = new RegExp("[*?'\"&\\\\]");     pattern.test(abc.value)