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>: fredname:<space>fredorname<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
iflag @ end. - if want name start lower or upper case n, use set
- if want entire regex case insensitive, add
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
Post a Comment