Home Blog LLC
In JavaScript, a regular expression is written in the form of /pattern/modifiers where "pattern" is the regular expression itself, and "modifiers" are a series of characters indicating various options. The "modifiers" part is optional.
* /g enables "global" matching. When using the replace() method, specify this modifier to replace all matches, rather than only the first one. * /i makes the regex match case insensitive. * /m enables "multi-line mode". In this mode, the caret and dollar match before and after newlines in the subject string.
You can combine multiple modifiers by stringing them together as in /regex/gim.
Since forward slashes delimit the regular expression, any forward slashes that appear in the regex need to be escaped. For example, the regex 1/2 is written as /1\/2/ in JavaScript.
As with anything, you can find much more information about JavaScript on the web if you Google or Bing it.
Friday, September 04, 2009 2:30:01 PM (Pacific Standard Time, UTC-08:00)
Comments [0] - Trackback
Code | JavaScript | jQuery
Sign up to get the CornerPixel Blog delivered to your email.
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2010 2008-2009 CornerPixel LLC
Sign In