PDA

View Full Version : Matching a set of numbers using regular expressions


WA
12-25-2002, 07:51 AM
Hi:
Lets say I wish to match a set of numbers, such as 3, 25, 6, 5 using regular expressions. What would the expression be? Something like:

[32565]

obviously doesn't work. How would I seperate the numbers?

Thanks for the help.

Kiwi
12-25-2002, 10:20 AM
Do you mean specific numbers (and in a spcific order) or any numbers in any order?

To match any of the number combinations in your list, you could use something like:
/(3)(25)(6)(5)/

WA
12-25-2002, 01:09 PM
Thanks Kiwi. I mean the given set of numbers, though only one of them at a time, so order is irrelevant. In other words, return a match if x is either 3, 25, 6, or 5.

I just figured this might work:

3|25|6|5