How can I match all characters between 2 specified characters, say \" \"
->
from sdfsf \" 12asdf \" sdf
I want to get 12asdf
o
I suggest you use
(?<=")(?:\\.|[^"\\])*(?=")
This will match only what is between the quotes (not the quotes themselves) and also handle escaped quotes inside your string correctly.
So in "She said, \"Hi!\""
, it will match She said, \"Hi!\"
.
If you're using JavaScript or Ruby (which you didn't mention) and therefore can't use lookbehind, use
"((?:\\.|[^"\\])*)"
and work with the capturing group no. 1.