How to use the build function from xregexp
Find comprehensive JavaScript xregexp.build code examples handpicked from public code repositorys.
118 119 120 121 122 123 124 125 126 127
Opting in to astral mode disables the use of `\p{…}` and `\P{…}` within character classes. In astral mode, use e.g. `(\pL|[0-9_])+` instead of `[\pL0-9_]+`. XRegExp uses Unicode 6.2.0. ### XRegExp.build In browsers, first include the script: ```html
90
165
25
+ 5 other calls in file
123 124 125 126 127 128 129 130 131 132
### XRegExp.build Build regular expressions using named subpatterns, for readability and pattern reuse: ```js const time = XRegExp.build('(?x)^ {{hours}} ({{minutes}}) $', { hours: XRegExp.build('{{h12}} : | {{h24}}', { h12: /1[0-2]|0?[1-9]/, h24: /2[0-3]|[01][0-9]/ }),
1
1
3
+ 5 other calls in file
xregexp.exec is the most popular function in xregexp (52 examples)