I'm trying to match symbol sequence according to these rules:
- it's located at the start of the string
- case insensitive
- it begins with letter
V
orN
- optional space follows
-
or–
characters follows (only one of them)- optional space follows
Here are example strings that it should match and expression I tried to make using google results :) :
var str = "V - ";
/*var str = "N - ";
var str = "V- ";
var str = "N -";
var str = "N –";
var str = "V– ";*/
str.replace(/^(V|N)\s(-|–)\s/i, 'replaced');
alert(str);
However it doesn't seem to work. Can someone help me please and explain how it is used, what I did wrong? Thanks