Search Posts

Category: regex

Regex to avoid all zero in the masked text box

I want to avoid “000-000-0000” in my text box. <div class=”inner-addon right-addon”> <input id=”PhoneHtmlId” type=”text” class=”form-control” maxlength=”12″ autocomplete=”off” patternValidator=”” validation [controlRef]=”form.controls.HomePhone” [requiredValidator]=”true” formControlName=”Phone” name=”PhoneHtmlId” [mask]=”{ mask: ‘999-999-9999’, placeholder: ‘___-___-____’, clearIfNotMatch: false }” /> </div> It is a masked text box. I need a patternValidator that is regex to avoid it. Can you please help me in writing regex for the same. Source: AngularJS

Using regex in Javascript to replace a part of the string

I have some text I am trying to replace a part of with regex in Angularjs. The text will be in the format: Name: Jane Age: 66 Address: 31 Test Street I would like to replace the part after Age: with ‘REDACTED’ (so 66 will not appear), so I have created this filter which to me seems like it should work: angular.module(‘person’) .controller(controllerId, personControl) .filter(‘ageFilter’, function () { return function (text) { if (text) return […]

Looking for help a regex that prevents special characters except ‘, space and – in the string but disallows them at the start

I have been scouring the internet for answers to this regex question and I have come quite close to getting it but I think I am missing one or two more groups to prevent the special characters at the start and end of the string. It is for use in angularJS and the full specification is a string of letters that cannot be longer than 20 characters, will only allow -,’ and space as the […]

how to compare two string regardless of lowercase and uppercase using angular js [duplicate]

This question already has an answer here: JavaScript case insensitive string comparison 15 answers Hi I need to compare two strings regardless of the case of the letters (uppercase/lowercase). <tr ng-repeat=”x in vm.partners”> <td ng-if = “‘vm.partner.name’ === ‘vm.partners.name'” colspan=”2″>{{ x.name }}</td> <td ng-if = “‘vm.partner.name’ === ‘vm.partners.name'” colspan=”2″>{{ x.contact.city.name }}</td> </tr> I want to check(vm.partner.name) and (vm.partners.name) both two string are same in and pattern. I want to keep regex pattern, so please tell […]

AngularJS (1.6) – Using regex to limit account IDs input in a field

I have a form on a website using Angular 1.6 and one of the fields allows users to input account IDs on which an action should be performed. (There are actually several of these forms all powered by the same controller.) Users are asked to separate the IDs by any non-alphanumeric character. On some instances of these forms, however, I need to restrict the number of IDs that can be specified. (All IDs fit the […]

Regex-replace text when text contains more than one dot

I have to make a regex that replace text except numbers and only one dot Here is my regex:: var a = text.replace(/[^0-9,.]/g, ”); But it does not replace dot. I have to replace dots more than one. here is the code: <!DOCTYPE html> <html> <script src=”https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js”></script> <body> <div ng-app=”myApp” ng-controller=”myCtrl”> <input production-qty ID=”test” ng-model=”testmodel” type=”text” /> </div> <script> var app = angular.module(“myApp”, []); app.directive(‘productionQty’, function () { return { require: ‘ngModel’, link: function (scope, […]

angularjs ng-pattern regex for 4 digits and 2 decimal

I am trying to create a Regex for a number with maximum 4 digits and if the input has decimal it has to have 2 digits – .20 and not .1. tried: ng-pattern=”/^[0-9]+(.[0-9]{1,2})?$/” //fail for 666666, .10, .1 Examples for valid inputs: 100.10 100 3000.10 Example for invalid: 10000 //has more then 4 digits before decimal 100.1 //has only 1 digit after decimal .10 //has no digits before decimal Thanks for any help. Source: AngularJS

Special characters in ng-pattern

So I have two inputs in my html. The second input has an ng-pattern=”pw”, where pw is the scope variable bound to the first input’s ng-model. I’m using this for password validation. I want the user to verify the password in the first input. This works fine except when regular expression reserved characters are being used. Ex: input1: !123 input2: !123 the ng-pattern will match these input1: $123 input2: $123 the ng-pattern will not match […]

Next Page »