omiz
omiz

Reputation: 949

Regular expression special

I only wanna see few characters in my website in the filed section. My regex code in the backend is: [(validator.field) = {regex: "^([0-9][+:\\-\\;]?)+"}]; and it's not working. Any help

So the user should only insert numeric (0-9), ; (semicolon) and : (colon).

Upvotes: 1

Views: 53

Answers (1)

Mohammad Javad Noori
Mohammad Javad Noori

Reputation: 1227

If user can put (; and :) in between numbers, you can use [\d;:]+$.

See an online demo.

However, if you need to match digits first and : or ; after them, use ^\d+[;:]+$.

See another demo.

Upvotes: 1

Related Questions