javascript - Check if text is in a string -



javascript - Check if text is in a string -

i want check text in string instance have string

str = "car, bycicle, bus"

and have string

str2 = "car"

i want check if str2 in str.

i newbie in javascript please bear me :)

regards

if(str.indexof(str2) >= 0) { ... }

or if want go regex route:

if(new regexp(str2).test(str)) { ... }

however may face issues escaping (metacharacters) in latter, first route easier.

javascript

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -