dschmierer

02-21-2007, 04:31 AM

Hi,

I'm trying to come up with a regular expression to use in a database query that, when given an input, will match itself and substrings of itself.

For example, say as my input I have: 25504010

Now I would like to query the DB for any of the following (every 2 digits stand for a different category):

25504010 (the input itself!)

255040 (the first substring I'm interested in)

2550 (another substring)

25 (another substring)

Is there a regex that can do this? I suppose I can always add a bunch of OR conditions to the DB query but this seems like something a regex can solve, I just can't think of the solution! :rolleyes:

Thanks in advance for any thoughts,

Dave

I'm trying to come up with a regular expression to use in a database query that, when given an input, will match itself and substrings of itself.

For example, say as my input I have: 25504010

Now I would like to query the DB for any of the following (every 2 digits stand for a different category):

25504010 (the input itself!)

255040 (the first substring I'm interested in)

2550 (another substring)

25 (another substring)

Is there a regex that can do this? I suppose I can always add a bunch of OR conditions to the DB query but this seems like something a regex can solve, I just can't think of the solution! :rolleyes:

Thanks in advance for any thoughts,

Dave