Sunday, 15 July 2012

javascript - Match regex dont seperate uppercase or not uppercase -


I am searching on the site, but my issue could not be answered. I have JavaScript Regex patterns that match some words and numbers. If I use a keyword "gem" and "gem" in my input string, then because of the fact no match is found that the word begins with uppercase letters. If any word is in uppercase letters, how can I prevent regex? My current code:

  var count = (countDescription.match (new RegExp ('(\\ b) (' + u + ') (\\ b)', 'g')) || []) Length;  

You should use the i option:

  var count = (countDescription.match (new RegExp ('(\\ b) (' + u + ') (\\ b)', 'gi')) []) Length ;  

No comments:

Post a Comment