Tuesday, January 26, 2016

Contains Sub String in a String JavaScript

Contains Sub String in a String JavaScript

var charString = "Hyderabad is a beautiful city";
        var regExp = new RegExp("beauti");
        if (regExp.test(charString.toString()))
        {
            alert('True')
        }
              
        var regExp = new RegExp("beda");
        if (regExp.test(charString.toString())) {
            alert('True city')
        }
        else {
            alert('false');

        }

No comments:

Post a Comment