Home > OS >  Turn off regular expressions in Visual Studio Code Search
Turn off regular expressions in Visual Studio Code Search

Time:03-22

Is there a way to turn off regular expressions when searching in VS Code? Oftentimes, when searching for a specific line of code (or partial line), VS Code interprets the search string as an "Invalid regular expression". I just want to do a search on a literal string without VS Code attempting to interpret the entry as a regular expression. I do not see any way to turn this off in the Features / Search options.

CodePudding user response:

Click on the .* symbol on the right side of the Find/Search box to disable the regular expression mode. Alternatively hit Alt R when the the Find/Search box is active.

Image showing the Regular Expression mode button.

The .* icon is used more often to represent a regular expression. It is itself a regular expression consisting of . meaning any character (except for line terminators) and the * quantifier meaning "0 or more occurrences". It effectively means "match anything".

  • Related