开发者

regular expression for quotes and whitespaces

I have this expression

("[^"]+")|(\s\S*\s)

which gets any characters that are in quotes and with white spaces around it.

Seems to work ok, but i was wondering if its possible to get just the characters inside the quotes and whitespaces.

I tried: ("[^"]+")|([^\s]\S*[^\s]) but i am not sure how to do the same for quotes as it will mess it up if i try the same thing.

Sample

This is "a short" little sentence!

With the regex it should return

This is a short little sentence!

instead of _This_ _is_ "a short" _little_ _sentence!_

where _ = a space

There are spaces include开发者_StackOverflow中文版d before and after and the quotes are still there too.

Thanks.


This is just a guess from your descriptions.

"([^"]+)"|\s(\S*)\s

Samples will produce better regex.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜