Thursday 15 January 2015

regex - Character '^' with regular expression in javascript -


What is the character to note about regxep matching in Javascript ^ ? It seems that this is a special character:

  "x ^ 2" .mail (/ [AG] + [0- 9] * /)   < P> Returns:  
  ["x ^ 2"]    

"^" is not particularly considered, it only comes between "A" and "Z" in ACI (see). Instead of limiting only the English alphabet, try to match against [a-zA-Z] pattern.

  "x ^ 2" .mail (/ [a-zA-Z] + [0] -9] * // // returns ["x"]    

No comments:

Post a Comment