Re: REGEX query

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

 



I assume that the text inside can change around a fair bit.  If the
string is of a fixed with or simple format you can just use substr() and
friends, it's simpler and faster.

That said, there is really two approaches that I can see with this string.

You can match on the spaces to extract the 'RV-6', something like
'/\s\S+\s/' should do the trick, that pulls out some non-whitespace
characters from between two whitespace characters, including the
whitespace characters.  Then just add the () on again afterwards.

The other approach would be to use preg_replace to get rid of the \(EX\)
portion by replacing it with an empty string.  Personally I would
probably use the first technique as I generally don't like using replace
functions in this way.  A pattern which should match is '/\\\(.*?\)\\/',
the mess of \ is because \ ( and ) all need to be escaped with a \.


David

phplists wrote:
> Hi,
> 
> I'm still trying to get to grips with REGEX and have hit a hurdle with
> the following:
> 
> I have this bit of text:
> (\(EX\) RV-6 )
> 
> I want to remove the '\(EX\)' part of it
> so leaving just: ( RV-6 )
> 
> Any suggestions would be most appreciated.
> 
> Thanks
> Alexis
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[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