Angular & RegExp checking
by BinaryAcid
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<html ng-app>
<h1>Select: Hello</h1>
<h1>Within: Hello world</h1>
/<input type="text" id="input" ng-model="name">/g
<h2>{{name}}</h2>
JavaScript
var str="Hello world";
var ansr="Hello";
$(document).keypress(function (e) {
setTimeout(grabVal, 100)
});
function grabVal(){
var input = $('#input').val();
var patt = new RegExp(input, "g");
var result=patt.test(str);
alert(result);
}