AngularJS Example:
HTML
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<div ng-app>
<h2>Todo</h2>
<div ng-controller="TodoCtrl">
<input type="text" ng-model="searchText"/>
<div>Hello</div>
<div ng-show="show">World !</div>
</div>
</div>
JavaScript
function TodoCtrl($scope) {
var reg = /20\d{2}/g;
var isValid = function(str) {
$scope.show = reg.test(str);
}
$scope.$watch('searchText',isValid);
}