Ive tried to get the regex to work so that only text between double quotes is splitted with the preg_split function, but it's final expression i'm having trouble with. Here's my code:
Code: Select all
$test = 'This is "just" a test. But "hopefully" some1 will get it to "work!';
$string1=preg_split('/(\".*?\")+(.*?)/',$test,-1,PREG_SPLIT_NO_EMPTY);
$pattern = '/.*?"(.*?)"/';
$string= preg_split ($pattern, $test, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);So my problem is that the last piece of text is splitted into the array while I only want "just" and "hopefully" in array.
Hopefully someone can help me on this last part of the regex expression..
Thanks..