Re: Regular expressions, filter option1 OR option2
| From: | Shreyas Agasthya | Date: | Wed, 18 Aug 2010 18:06:59 +0000 |
| Subject: | Re: Regular expressions, filter option1 OR option2 | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-307538@lists.php.net to get a copy of this message | ||
Camilo,
What exactly are you trying to achieve? Meaning:
if (true)
do this;
if (false)
do that;
However, here's a link that I used long back to help me with some RegEx :
http://www.gskinner.com/RegExr/
Regards,
Shreyas
On Wed, Aug 18, 2010 at 11:31 PM, Camilo Sperberg <csperberg@unreal4u.com>wrote:
> Hello list :)
>
> Just a short question which I know it should be easy, but I'm no expert yet
> in regular expressions.
> I've got a nice little XML string, which is something like this but can be
> changed:
>
> <?xml version="1.0" encoding="utf-8"?>
> <boolean
> xmlns="http://tempuri.org/">false</boolean>
>
> The boolean value can be true or false, so what I want to do, is filter it.
> I've done it this way, but I know it can be improved (just because I love
> clean coding and also because I want to master regular expressions xD):
>
> $result = preg_match('/true/',$curl_response);
> if ($result == 0) $result = preg_match('/false/',$curl_response);
>
> I've also tried something like:
> $result = preg_replace('/^(true)|^(false)/','',$curl_response); // if not
> true OR not false => replace with empty
>
> and also '/^true|^false/' which doesn't seem to work.
>
> Any ideas to filter this kind of string in just one expression?
>
> Thanks in advance :)
>
> --
> Mailed by:
> UnReAl4U - unreal4u
> ICQ #: 54472056
> www1: http://www.chw.net/
> www2: http://unreal4u.com/
>
--
Regards,
Shreyas Agasthya