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
fork icon90
star icon165
watch icon25

+ 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]/
    }),
fork icon1
star icon1
watch icon3

+ 5 other calls in file