Regex in JS
Quiz
"Hello world".search(/le?/g)
3 letters "l"
/el?/g
"Hello world"
part "el"
/el+/g
"Hello world"
part "ell"
"Hello world"
/el??/g
"Hello world"
/el??/g
"Hello world"
part "e"
"Hello world"
/el+?/g
"Hello world"
part "el"
"Hello world"
/el*/g
"Hello world"
part "ell"
"Hello world"
/el*?/g
"Hello world"
letter "e"
"Hello world"
/l{1,2}/g
"Hello world"
parts "ll" and "l"
"Hello world"
/l{1,2}?/g
"Hello world"
3 letters "l"
"Hello world"
/^h/g
"hello hard world"
first letter "h"
"hello hard world"
/d$/
"hello hard world"
last letter "d"
"hello hard world"
/b(?=a2|a3)/g
"a1ba2ba3b"
2 letters "b"
"a1ba2ba3b"
/b(?!a2|a3)/g
"a1ba2ba3b"
last letter "b"
"a1ba2ba3b"
/(?<=a1|a2)b/g
"a1ba2ba3b"
2 letters "d"
"a1ba2ba3b"
/(?<!a1|a2)b/g
"a1ba2ba3b"
last letter "d"
"a1ba2ba3b"
/\bW/g
"Hello World_1"
letter "W"
"Hello World_1"
/\w\d/g
"Hello World_1"
part "_1"
"Hello World_1"
/\Bd/g
"Hello World_1"
/\u{1f933}/g
"💏🤳"
Nothing
"💏🤳"
/\u{1f933}/gu
"💏🤳"
🤳
"💏🤳"
/\p{Script=Latin}/gu
"πüé HelloWorld"
letters "ü", "é", "H", "e", "l", "l", "o", "W", "o", "r", "l", "d"
"πüé HelloWorld"
/\p{Script=Greek}/gu
"πüé HelloWorld"
letter "π"
"πüé HelloWorld"
/\p{White_Space}/gu
"πüé HelloWorld"
/(?<year>[0-9]{4})-(?<month>[0-9]{2})-(?<day>[0-9]{2})/g
"2018-05-22"
Whole date split by groups
"2018-05-22"
/^(?<word>\w+)!\k<word>$/g
"abc!abc"
whole phrase
"abc!abc"
/^(\w+)!\1$/g
"abc!abc"
whole phrase
"abc!abc"
/abc./g
"abc\nabc"
nothing
"abc\nabc"
/abc./s
"abc\nabc"
abc\n
"abc\nabc"
/abc/yg
"abc\nabc"
abc
"abc\nabc"
https://github.com/life777/regex-help
Regex in JS
By Vladimir
Regex in JS
- 140