-2

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?

GitaarLAB
  • 14,536
  • 11
  • 60
  • 80
  • 2
    This 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 Answers3

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
  • 630,263
  • 148
  • 957
  • 1,375
1

This is regexp(regular expression).

http://www.regexr.com/

/[SOME CONTENT]/ 

"/" means inner content is regExp

then last "g" means search global

easywaru
  • 1,073
  • 9
  • 17
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

enter image description here

Bijan
  • 7,737
  • 18
  • 89
  • 149