How to use the tag function from xregexp
Find comprehensive JavaScript xregexp.tag code examples handpicked from public code repositorys.
144 145 146 147 148 149 150 151 152 153
Provides tagged template literals that create regexes with XRegExp syntax and flags: ```js const h12 = /1[0-2]|0?[1-9]/; const h24 = /2[0-3]|[01][0-9]/; const hours = XRegExp.tag('x')`${h12} : | ${h24}`; const minutes = /^[0-5][0-9]$/; // Note that explicitly naming the 'minutes' group is required for named backreferences const time = XRegExp.tag('x')`^ ${hours} (?<minutes>${minutes}) $`; time.test('10:59'); // -> true
1
1
3
+ 3 other calls in file
118 119 120 121 122 123 124 125 126 127
XRegExp('^\\p{Hiragana}+$').test('ひらがな'); // -> true XRegExp('^[\\p{Latin}\\p{Common}]+$').test('Über Café.'); // -> true // Test the Unicode categories Letter and Mark // Can also use the short names \p{L} and \p{M} const unicodeWord = XRegExp.tag()`^\p{Letter}[\p{Letter}\p{Mark}]*$`; unicodeWord.test('Русский'); // -> true unicodeWord.test('日本語'); // -> true unicodeWord.test('العربية'); // -> true ```
0
2
1
+ 3 other calls in file
xregexp.exec is the most popular function in xregexp (52 examples)