RegExp

JavaScript natively supports regular expressions via the object type RegExp, allowing them to be expressed via the literal syntax /foo/ or directly via the constructor (RegExp('foo')).  Regular expressions are used to define patterns of characters that can be matched or executed against strings. 

Here is an example in which we extract only the long words (>=10 characters) from a corpus of text:

const string = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam sit amet odio ultrices nunc efficitur venenatis laoreet nec leo.';

string.match(/w{10,}/g); // => ["consectetur", "adipiscing"]
The grammar and syntax of regular expressions can be complex. It is technically an entire language unto itself, requiring many days of study. We won't be able to explore all of its complexity here. We will, however,  be covering the ways in which we typically operate on regular expressions within JavaScript and explore some of the challenges in doing so. It is suggested that you conduct further study into regular expressions yourself.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.107.229