Possible Duplicate:
PHP explode the string, but treat words in quotes as a single word.
i have a quoted string with quoted text. Can anyone give me the regex to split this up.
this has a \\\'quoted sentence\\\' inside
the quotes may also be single quotes. Im using preg_match_all.
right now this
preg_match_all('/\\\\"(?:\\\\.|[^\\\\"])*\\\\"|\S+/', $search_terms, $search_term_set);
Array
(
[0] => Array
(
[0] => this
[1] => has
[2] => a
[3] => \\\"quoted
[4] => sentence\\\"
[5] => inside
)
)
i would like this output
Array
(
[0] => Array
(
[0] => this
[1] => has
[2] => a
[3] => \\\"quoted sentence\\\"
[4] => inside
)
)
This is NOT a duplicate of this question. PHP explode the string, but treat words in quotes as a single word
UPDATE:
Ive removed the mysql_real_escape_string. What regex do i need now Im just using magic quotes.