JavaScript Regular Exp
JavaScript Regular Exp
The search pattern can be used for text search and text replace operations.
When you search for data in a text, you can use this search pattern to
describe what you are searching for.
Regular expressions can be used to perform all types of text search and text
replace operations.
Syntax
/pattern/modifiers;
Example
/w3schools/i;
Example explained:
In JavaScript, regular expressions are often used with the two string methods:
search() and replace().
The search() method uses an expression to search for a match, and returns
the position of the match.
The replace() method returns a modified string where the pattern is replaced.
The search() method searches a string for a specified value and returns the
position of the match:
Example
let n = text.search("W3Schools");