Javascript Regex for colon? -


i'm wondering how can use javascript regex match word like:

name:

with variations of spaces ? i'm getting stuck. i.e.

  • name<space>: fred
  • name:<space>fred or name<space>:<space>fred

note positioning of spaces after name, after colon etc ?

i hoping /(name(\s*:\s*)?)\w/g work doesn't :(

  • name starts capital letter. regex should match name starting capital n.

    • if want entire regex case insensitive, add i flag @ end.
    • if want name start lower or upper case n, use set
  • the * means 0 or more. ? not needed anymore.

something should work

/name\s*:\s*\w*/g    //matches "name"  /[nn]ame\s*:\s*\w*/g //matches "name" or "name"  /name\s*:\s*\w*/gi   //the entire regex case insensitive 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -