# Category: regex

## 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, […]