Page 1 of 1

regex for qouted text

Posted: Mon Oct 02, 2006 5:12 am
by kreoton
Hi i making regex for quoted text, but i have no luck here is my code:

Code: Select all

if (eregi('^\"+[a-zA-Z]+\"$',$_REQUEST["dvd_search"])) echo 'zz';
Plz help to wtrite good regex :oops:

Posted: Mon Oct 02, 2006 6:02 am
by twigletmac
This regex (using PCRE) works for the test string I fed it:

Code: Select all

<?php

$string = 'test1 "test2 test2" test3 "test4"';

preg_match_all('/"+([\w\s]+)"+/', $string, $matches);

echo '<pre>';
print_r($matches);
echo '</pre>';
?>
This may not fit your needs - it would be useful to see the sort of string you would be matching against...

Mac

Posted: Mon Oct 02, 2006 8:53 am
by kreoton
thanks

Posted: Tue Oct 03, 2006 7:51 am
by feyd
We had a thread some time ago on doing this:

viewtopic.php?t=36790