|
Posted by Gleep on 05/22/07 03:45
On Tue, 22 May 2007 01:28:10 GMT, "cluthz" <WHATEEVVEERR@by.co.uk> wrote:
>Help,
>
>I'm having this strange problem where my regular expression will not match
>blank space.
>
>Obviously I'm doing something wrong, but what?
>
>Lets say I have a string such as
>
>$test = "my example"
>
>then I want to search it for a string
>ereg ("\se",$test)
>
>I would expect the above to return true but it returns false.
>
>When I amend it to:
>ereg ("e",$test)
>
>I get a true response as expected.
>
>when I try
>ereg ("\s",$test)
>
>It returns false. (I would expect true as there is a space in the string).
>
>Please tell me what I'm doing wrong. It's driving me nuts
>
>Thanks in advance.
>
try ereg ("( e)",$test)
or ereg ("\s+e",$test)
you need to read-up on regex
there are plenty of tutorial online
they can be very tricky
http://www.dhtmlgoodies.com/scripts/regular-expression/regular-expression.html
i attached a cheat sheet
Navigation:
[Reply to this message]
|