|
JavaScript offers built-in support for regular expressions. Here are some examples of common regexp-related tasks. |
|
|
There are two ways to create a Regular Expression object: |
|
|
The Literal notation takes a pattern between two slashes, followed by optional flags, after the second slash. |
|
|
The constructor function takes either a string or
an existing |
|
|
In JavaScript these are all equivalent.
To test against a string we can call |
|
|
Using a regular expression to change data format in a string. |
|
|
Splitting lines with different line endings. |
|
|
Next example: JSON.