Creating a Regular Expression You construct a regular expression in one of two ways: Using a regular expression literal, as follows: var re = /ab+c/; Regular expression literals provide compilation of the regular expression when the script is loaded. When the regular expression will remain constant, use this for better performance. Calling the constructor function of the var re = new RegExp("ab+c"); Using the constructor function provides runtime compilation of the regular expression. Use the constructor function when you know the regular expression pattern will be changing,
Read full article from Regular Expressions - JavaScript | MDN
No comments:
Post a Comment