Regex to search for a word in a string in Visual Studio

前端 未结 5 1516
梦毁少年i
梦毁少年i 2021-02-04 04:02

I need to search all of my codebase for \"Url\" and replace it with \"URL\". If I search for Url in Visual Studio I also get all my variables with \"Url\" in it.

Anyone

5条回答
  •  萌比男神i
    2021-02-04 04:21

    What I really ended up needing was:

    ("[^"]*Url[^"]*")
    

    And thanks to the tip from tghw who pointed out the :q shortcut in Visual Studio equates to:

    (("[^"]*")|('[^']*'))
    

    I realized I needed to use the first portion to find only the double quoated strings I was looking for.

    Both this regex and a standard find with 'Match case' and 'Match whole word' yielded results with some strings I was hoping to not find but eliminated the code with 'Url' in it.

提交回复
热议问题