Search code examples
regexeclipselookbehind

Regular expression to match not the beginning/end of a line


I would like a regular expression to match only " that

  • don't come at the start of a line or after white space at the start of a line
  • don't come at the end of a line or before white space at the end of a line

I guess I need to use lookbehind and lookahead.

So matches the " in

zfgjhsgaf jhsa gd " gjhygf" hgf

But not in

"gjhgjkgjhgjhgkk"

      "dfsdfsdf"   

Solution

  • For Eclipse, try finding by this regex:

    (?<!^\s*)"(?!\s*$)
    

    And replacing with:

    \"