Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
95
rated 0 times [  98] [ 3]  / answers: 1 / hits: 16068  / 11 Years ago, sat, june 8, 2013, 12:00:00

I need a regular expression pattern that matches any number including 1-9 numbers except 2?



My attempt:



([1-9][^2])


But this doesn't work for me.


More From » jquery

 Answers
21

You can match the range of numbers before and after two with [0-13-9], like this:



4526.match(/[0-13-9]+/)
[45]
029.match(/[0-13-9]+/)
[0]
09218.match(/[0-13-9]+/)
[09]

[#77740] Friday, June 7, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
richardaydenc

Total Points: 148
Total Questions: 125
Total Answers: 98

Location: Seychelles
Member since Mon, Jun 28, 2021
3 Years ago
;