Search Posts

Category: regex

Hi I need a regex expression in angularjs for matching file path similar to var/log or /home/test/logs

Hi I am getting file path in text box as multiple input seperated by semicolon. and I am using ng-list for separating and storing it in model. Now I need to perform a ng-pattern check for this. should not contain only single work like filepath. should contain / but not // It will be separated by , as now the value is ng-list. So it should take that string and check wether / is present. […]

Find and replace in atom with regex

I have bought theme that includes too many things like this: $(“.search-toggle”).click(function() { … However the function wont get fired since I am using AngularJS components and the actual search-toggle class is found in a nested page. The only way to reach it and make it fired is like that: $(document).on(‘click’, ‘.search-toggle’, function() { … As I said there tons of such things and I either do not find efficient and fast way to switch […]

Uses of regex in condition form

I have a little problem with my code. I would like to only show the key stored in my storage which began with a ‘ [ “. I don’t know if I have to use the Angular – Pattern because i don’t really understand how it works. Here is my code: constructor(public navCtrl: NavController,public _storage: Storage){ this._storage.forEach( (value, key, index) => { //console.log(“This is the value”, value) //console.log(“from the key”, key) //console.log(“Index is”, index) this.questionnaires.push(key); […]

Cannot access this when bg-keyup is called the second time

There is an input field like: <input ng-if=”$ctrl.inputType === ‘input'” name={{$ctrl.param.Name}} type=”text” ng-keyup=”$ctrl.keyp()” …” /> and the keyp() function in controller: keyp() { const dec = 2; const regex = new RegExp(“(.d{” + dec + “})d+”, “g”); this.param.value = this.param.value.replace(regex, ‘$1’); } The aim is to make possible to introduce maximum of 2 digits after the decimal point. I had put a debbuger inside keyp() to see how it is behaving. When there is added […]

How to set regex pattern in a function using ng-pattern

Is it possible to set ng-pattern to something which is return in function? My pattern is create dynamically (depends on what is click on the site), so I need something like this: <input ng-pattern=”myPattern()”> $scope.myPattern = function(){ var list = listFromServer.join(‘|’); return new RegExp(“^(?!.*(“+list+”)).*$”) } But it obviously doesn’t work. How can I deal with it and create dynamic regex pattern if my ‘listFromServer’ is also dynamically and depends on user clicking? Source: AngularJS

Check first character of a word in a string begins with @

A few days ago I posted a similar question, but I do not quite understand the principle. Are there good resources where the replace function combined with regular expressions is explained? Anyways, right now I have the following problem: A string which starts with @ should be placed in an link. So @test should be replaced to <a href=”/test”> @test </a>. Also, these rules should apply: The string can only contain one @, which is […]

Exclude list of string in validation – regex [duplicate]

This question already has an answer here: How to negate specific word in regex? 10 answers I need to validate input: when user type one of 3 words from list (array is in js file), I need to have error (in this case below, if user type test1, test2, or test3 you will see error, otherwise everything should be fine) file.html <input type=”text” ng-pattern=”regexPatter” /> file.js var array = [“test1”, “test2”, “test3”] var excludeWords = […]

How to prevent input type number from accepting numbers in e format

I am using input type number in my html page but I don’t want the numbers in e format . I am trying to use a regex like follows: $scope.regexInteger = ‘^[0-9^e]*$’; and trying to invalidate it using ng-messages <input type=”number” maxlength=”20″ class=”w3-input w3-border w3-round-large” ng-pattern=”regexInteger” name = ‘intVal’ /> <div ng-messages=’intVal’ > <div ng-message=”pattern”>Invalid Integer</div> </div> But I am not able to invalidate it using the ng-messages. I guess I am not passing the […]

Next Page »