84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
var reg = new RegExp('\w'); var match = reg.exec('/hello/world/1'); console.log(match[0]);
The above log prints h. If you want to print hello, how do you do it?
var reg = new RegExp('\b\w+\b'); var match = reg.exec('/hello/world/1'); console.log(match[0]);
bMatch the beginning or end of a word.
b
var pattern = /hello/;
var str = "helloword"; console.log(pattern.exec(str)[0]);
Recommend you this website http://www.runoob.com/regexp/...
First w matches the literal value wwmatches the characters appearing in the word, such as a to z and_If you need to match multiple
w
_
You can add*at the end to indicate 0 or more
*
You can add+at the end to indicate one or more
+
/[a-zA-Z]*/
b
Match the beginning or end of a word.var pattern = /hello/;
Recommend you this website http://www.runoob.com/regexp/...
First w matches the literal value w
w
matches the characters appearing in the word, such as a to z and_
If you need to match multiple
You can add
*
at the end to indicate 0 or moreYou can add
+
at the end to indicate one or more