A global search for whitespace characters: lettext ="Is this all there is?"; letpattern =/\s/g; Try it Yourself » Description The \s metacharacter matches whitespace character. Whitespace characters can be: A space character A tab character ...
A global search for non-digit characters: lettext ="Give 100%!"; letpattern =/\D/g; Try it Yourself » Description The \D metacharacter matches non-digit characters. Browser Support /\D/is an ECMAScript1 (JavaScript 1997) feature. ...
JavaScript RegExp - p.p JavaScript RegExp - ^.{2}$ JavaScript RegExp - (.*) JavaScript RegExp - p(hp)* Literal Characters JavaScript RegExp - Alphanumeric JavaScript RegExp - \0 JavaScript RegExp - \t JavaScript RegExp - \n JavaScript Reg...
Assertions appear as separate AST nodes, however instread of manipulating on the characters themselves, they assert certain conditions of a matching string. Examples: ^ -- beginning of a string (or a line in multiline mode), $ -- end of a string, etc....
Example A global search for non-word characters: let text = "Give 100%!"; let pattern = /\W/g; Try it Yourself » Description The \W metacharacter matches non-word characters: A word character is a character a-z, A-Z, 0-9, including _ (underscore)....
A global search for word characters: lettext ="Give 100%!"; letpattern =/\w/g; Try it Yourself » Description The \w metacharacter matches word characters. A word character is a character a-z, A-Z, 0-9, including _ (underscore). ...
lettext ="Visit W3Schools.\0Learn Javascript."; letpattern =/\0/; Try it Yourself » Description The \0 metacharacter matches NUL characters. Browser Support /\0/is an ECMAScript1 (JavaScript 1997) feature. It is supported in all browsers: ...
Search for a carriage return character in a string: lettext ="Visit W3Schools.\rLearn Javascript."; letpattern =/\r/; Try it Yourself » Description The \r metacharacter matches carriage return characters. Browser Support /\r/is an ECMAScript1 (JavaScript 1997) feature. ...
Description The \0 metacharacter matches NUL characters.Browser Support/\0/ is an ECMAScript1 (JavaScript 1997) feature.It is supported in all browsers:Chrome Edge Firefox Safari Opera IE Yes Yes Yes Yes Yes YesSyntaxnew RegExp("\\0") or simply: /\0/...