[thelist] PHP- simple reg-ex has me stumped

mjunkie at dse.nl mjunkie at dse.nl
Wed May 8 04:26:01 CDT 2002


Hello Stephane,

<snip>
SG> ^[a-zA-Z0-9\/_/-]+$

SG>   Now. I got that far. I fail to understand the \ right after the 9, is it
SG> same as |, the 'or' operator?
</snip>

It's an escape character.  It should escape the / behind it.

This is quite an awkward regex though. I havent delved into it lately
but I think this should do it far more easily :
^[\w\d\-\_]$ (the plus means it has to contain at least one character)

If you want a space add \s to the list


SG>   I need the same regex above to simply accept spaces....i have tried all
SG> kinds of /s /s. \s \s,[spaces]... etc

SG> This regex: ^[a-zA-Z0-9\s.\-]+$ , wich has to be close to solving my
SG> problem works good on http://regxlib.com/RETester.aspx?regexp_id=63
SG>   BUT fails in my php script with the ereg function, also tried preg_match,
SG> no go. What s the prob?
-->> ANy addtional links to docs or man pages would be appreciated. Thnks.


SG> * My regex makes my tip. :)

SG> <Tip>
SG> PHP - Reg EX:
SG> This matches a string that can contain any alphanumeric caracters , the
SG> dash and the underscore.
SG> ^[a-zA-Z0-9\/_/-]+$
SG> <\Tip




--
Best regards,
 Michiel                            mailto:M.B.Trimpe at student.tue.nl





More information about the thelist mailing list