Page 1 of 1
easy regex question... I'm just not smart enough
Posted: Mon Jun 11, 2007 10:27 am
by orfeus123
Hey there
I'm trying to embed a regex variable in this URL and I can't seem to figure out which is the right one.
The link example is:
http://strategy.thesuccessleague.com/MV ... PURLPage=7
I need to find a regex variable that will replace "MVanDusen" (It's always someone's name, so the length will very from person to person)
I tried this:
http://strategy.thesuccessleague.com/[:alnum:]?elqPURLPage=7
but it didn't seem to work
Any help would be beautiful
Thanks!
Posted: Mon Jun 11, 2007 10:58 am
by superdezign
Look at it this way. You want everything between the "/" and the "?". The chances of them coming up more than once is very slim, and they'll always be the first match anyway.
Posted: Mon Jun 11, 2007 11:05 am
by orfeus123
But is the [:alnum:] tag the right way to do that? Or is there a better tag for that? I'm new to regex codes so I'm a little lost in general...
Thanks a lot.
Sincerely,
The Regex Retard
Posted: Mon Jun 11, 2007 11:21 am
by superdezign
I am utterly clueless as to what an [:alnum:] tag is.
Posted: Mon Jun 11, 2007 12:11 pm
by jayshields
AFAIK it's a pseudo class which is equivilent to stating [a-z0-9].
Something like that anyway, I'm not the best person to tell

Posted: Tue Jun 12, 2007 12:32 pm
by GeertDD
[:alnum:] is a POSIX character class and not compatible with PCRE. I guess it is equivalent to [a-zA-Z0-9].
Try this regex:
Code: Select all
#http://strategy\.thesuccessleague\.com/(.*?)\?elqPURLPage=7#
Posted: Tue Jun 12, 2007 8:00 pm
by feyd
[:alnum:] is supported by PHP's PCRE last I checked.
Posted: Wed Jun 13, 2007 1:19 pm
by GeertDD
feyd wrote:[:alnum:] is supported by PHP's PCRE last I checked.
Are they? Seems like you're right indeed, feyd. This surprises me. Did some test and as long as you put the POSIX character class inside a regular character class, it works (otherwise you'll get this error apparently: Compilation failed: POSIX named classes are supported only within a class).
Nice to know you
can use them, however I'm not a big fan and will probably avoid them anyway.
Posted: Wed Jun 13, 2007 8:35 pm
by feyd
Yeah, I'm not a fan either, but I suspect they were added for compatibility of converting ereg_* to preg_* quickly for many developers since regex is a very tough subject for many.