Reputation: 23550
I would like a regular expression to match only " that
I guess I need to use lookbehind and lookahead.
So matches the " in
zfgjhsgaf jhsa gd " gjhygf" hgf
But not in
"gjhgjkgjhgjhgkk"
"dfsdfsdf"
Upvotes: 1
Views: 466
Reputation: 31471
^\s*"?.*\S.*(").*?\S.*?"?\s*$
Which supports matching ' "foo"bar" ' assuming that is something that you want to find.
Oh, and it only matches if $1 is set
Upvotes: 0
Reputation: 93026
See this here
(?<!^)"(?!\s*$)
It works not for the whitespace after beginning of the line. As BoltClock mentioned, variable length look behind is supported only by few engines (I know only .net).
If you use a regex that support it, you can use
(?<!^.*)"(?!\s*$)
A good documentation for look ahead/behind is here in the perldoc.perl.org/perlretut.html#Looking-ahead-and-looking-behind
Upvotes: 0
Reputation: 724252
For Eclipse, try finding by this regex:
(?<!^\s*)"(?!\s*$)
And replacing with:
\"
Upvotes: 2