Re: Regular expressions, filter option1 OR option2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx>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

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux