regex for qouted text

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
User avatar
kreoton
Forum Commoner
Posts: 42
Joined: Fri Mar 03, 2006 7:27 pm

regex for qouted text

Post 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:
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
kreoton
Forum Commoner
Posts: 42
Joined: Fri Mar 03, 2006 7:27 pm

Post by kreoton »

thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

We had a thread some time ago on doing this:

viewtopic.php?t=36790
Post Reply