Search code examples
regexng-pattern

AngularJs text input field regular expression


Currently, I use the following expression for my ngPattern attribute: /[^*]/ meaning that any input is allowed but it has to contain at least one char different from *. Now, additional requirement arose - the input has to be numeric only.

Is there any possibility to combine these two requirements in one single regular expression? I just can't get it... Or should I move the condition check to my controller, where I would apply two regular expressions consecutively, programmatically.


Solution

  • OK, I asked a colleague of mine today. Here is the right solution: /[\d*]*\d[\d*]*/