String.search
example
var stringValue = "This is my test string to search";
var result = stringValue.search(/is|test|string/);
//if () {....}
//true return 6 false return -1
var str = "This is a sample text";
var re = /nothing|text|string/g
if (str.search(re) != -1) {
midstring = " contains ";
} else {
midstring = " does not contain ";
}
沒有留言:
張貼留言