Re: Regex help
| From: | Joona Kulmala | Date: | Sat, 19 Oct 2002 23:14:34 +0000 |
| Subject: | Re: Regex help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-120639@lists.php.net to get a copy of this message | ||
On Sat, Oct 19, 2002 at 06:55:43PM -0400, Gerard Samuel wrote:
> I have a quoted string, like so ->
> "test"
> Since the string may contain multiple words, Im using regex.
> Im trying ->
> $search_words = preg_replace('/\"(\w+|\s+)\"/', '$1', $keywords);
> It works great for one word. Using multiple words like ->
> "this is a test" fails.
This might be the regexp you are looking for.
$search_words = preg_replace("/\"([^\"]+)\"/", "$1", $keywords);
So now it matches anything but " between those quotes.
--
Joona Kulmala
joona@phpfi.org