Heidel
Heidel

Reputation: 3254

Regex for numbers and some characters

I try to make regex for checking value which can contain numbers 0-9, (), + and -. I tried this var checkRegex = /^([0-9]+[ ()+-]*)$/gmi; but it doesnt work https://regex101.com/r/eX6yH9/1. What did I do wrong?

Upvotes: 1

Views: 52

Answers (2)

Zeromus
Zeromus

Reputation: 4532

in the link you provided there is a pattern dd-dd-dd-dd dunno if that was a coincidence the other answer is good

\d\d([ ()+-]\d\d)*

Upvotes: 0

rock321987
rock321987

Reputation: 11032

This is the correct regex

^([0-9() +-]*)$

Regex Demo

Upvotes: 3

Related Questions