This is weird, I have this statement in js code:
alert ( "Hello @name , your account will be activated at @date".match(/@{1}[w_]+/g) );
When I run the code from the file (opening the file using browser)
I get
[hello,name,your,account,be,activated,date]
But when I run it on the chrome developer console
I get:
[@name,@date]
what is happening here? same code d/t result
update:
As @funkwurm tried to mention on the comment there is a change on the code when I inspect the page using chrome developer tool.
match(/@{1}[w_]+/g)
was changed to match(/[w_]+/g)
I am using Grails framework so I thought using the slashy syntax (/ /) was causing the problem because Grails also uses that syntax ( due to conflict).
so changed it to
var pattern = new RegExp("@{1}[\w_]+","g");
alert ( "Hello @name , your account will be activated at @date".match(pattern) );
but still no effect, and when I do alert(pattern)
I get /[w_]+/g
still without the @.
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…