JavaScript regex returns -1 when > 0 is expected -


okay have following string:

aktiv landbruger / regler al 

with string attempt run following regex:

/regler al/i 

however once run string.search('/regler al/i')

it returns -1

however when attempt on

https://regex101.com/

it returns 0 should.

so why javascript returning -1

remove single quotes around regex

"aktiv landbruger / regler al".search(/regler al/i) 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

apache - setting document root in antoher partition on ubuntu -