Jay said:
I am going to write a function that the search engine done.
in search engine, we may using double quotation to specify a pharse
like "I love you",
How can I using regular expression to sperate each pharse?
test case:
"I love" all "of you"
I would like it return:
"I love", all, "of you"
Here's a solution that meets your spec., but it is ugly and a stretch,
and I am not saying that I would do it this way

Over to the golfers...
----
#!/usr/bin/perl
use strict;
use warnings;
while (<DATA>) {
print "Original: $_";
s/(.?)("[^"]*")(.?)/{if ($1 && $3) {",$1$2,$3"} elsif ($3) {"$2,$3"}
elsif ($1) {",$1$2"} else {$2}}/ge;
print "Result: $_";
}
__DATA__
"I love" all "of you"
"I hate" almost "none of" you
I wonder "how this" will work "when" one "tests" a longer "example like
this?"
one
"two"
----
Output:
Original: "I love" all "of you"
Result: "I love", all, "of you"
Original: "I hate" almost "none of" you
Result: "I hate", almost, "none of", you
Original: I wonder "how this" will work "when" one "tests" a longer
"example like this?"
Result: I wonder, "how this", will work, "when", one, "tests", a longer,
"example like this?"
Original: one
Result: one
Original: "two"
Result: "two"
DS
PS. Leading or trailing whitespace will bite you.