I have seen the following code snippet used by other programmers in questions I am answering on coderbyte in javascript : /\b[a-z]/g
Can someone explain what this means / when it can be used?
Asked
Active
Viewed 5,112 times
-2
GitaarLAB
- 14,134
- 11
- 55
- 76
Martin Fielding
- 1
- 1
- 1
-
2This is called a [regular expression literal](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions). – Jon Nov 07 '14 at 00:08
3 Answers
4
It's a regular expression, composed of a word boundary and a character class, as a regexp literal.
In can be used to detect all lowercase letters at the beginning of a word.
Bergi
- 572,313
- 128
- 898
- 1,281
1
This is regexp(regular expression).
/[SOME CONTENT]/
"/" means inner content is regExp
then last "g" means search global
easywaru
- 993
- 8
- 16
0
This is a regular expression.
/\b[a-z]/g
selects the first letter of a word if it is lowercase
See below for an example of it being run on regexr.com
Bijan
- 6,563
- 14
- 74
- 130