Here you go:
The regex that I've used is:
1) (?=(.d){2}) --> atleast 2 digits
2) (?=(.[a-z]){2}) --> atleast 2 lower case chars
3) (?=(.[A-Z]){2}) --> atleast 2 upper case chars
4) (?=(.[!@#$%]){2}) --> atleast 2 special chars, can be any one of !, @, #, $, %
angular.module('myApp', [])
.controller('MyController', function($scope) {
$scope.password = '';
// (?=(.*d){2}) --> atleast 2 digits
// (?=(.*[a-z]){2}) --> atleast 2 lower case chars
// (?=(.*[A-Z]){2}) --> atleast 2 upper case chars
// (?=(.*[!@#$%]){2}) --> atleast 2 special chars, can be any one of !, @, #, $, %
$scope.pattern = /(?=(.*d){2})(?=(.*[a-z]){2})(?=(.*[A-Z]){2})(?=(.*[!@#$%]){2})/;
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="MyController">
<form name="myForm">
<label>Enter password: </label>
<input type="password" name="password" ng-model="password" ng-pattern="pattern">
<span style="color:red" class="error" ng-show="myForm.password.$error.pattern">Password is not valid, doesn't match the provided pattern.</span>
</form>
</div>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…