By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,934 Members | 1,476 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,934 IT Pros & Developers. It's quick & easy.

regular expression meaning here

pradeepjain
100+
P: 563
hii guys, sorry this might seem to be a silly question
what does /\b/g here means ,what is he trying to do with this code.
Expand|Select|Wrap|Line Numbers
  1.     var matches = $(field).val().match(/\b/g);
Nov 30 '09 #1
Share this Question
Share on Google+
3 Replies


Dormilich
Expert Mod 5K+
P: 8,639
usually a backspace or word boundary. guess it is testing an input field if there was something written in.
Nov 30 '09 #2

pradeepjain
100+
P: 563
it was used in a script for word count .
Nov 30 '09 #3

Frinavale
Expert Mod 5K+
P: 9,731
According to this regular expression reference:
\b: matches at the position between a word character (anything matched by \w) and a non-word character (anything matched by [^\w] or \W) as well as at the start and/or end of the string if the first and/or last characters in the string are word characters.
The /g applies the regular expression globally to what ever you are using (instead of stopping after the first occurrence that regex matches). For more information on global matching see the Advanced regular expression resource.

-Frinny
Nov 30 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.