What flavor of Regex does Visual Studio Code use?

Rust Regex in the Find/Replace in Files Sidebar

Rob Lourens of MSFT wrote that the file search uses Rust regex. The Rust language documentation describes the syntax.

Rob Lourens on GitHub

JavaScript Regex in the Find/Replace in File Widget

Alexandru Dima of MSFT wrote that the find widget uses JavaScript regex. As Wicktor commented, ECMAScript 5’s documentation describes the syntax. So does the MDN JavaScript Regular Expression Guide.

Alexandru Dima on GitHub

Test the Difference

The find in files sidebar does not support (?=foobar) whereas the find in file widget does support that lookahead syntax.

Shows a lookahead working in the widget but not in the sidebar.

Regarding Find/Replace with Groups

To find/replace with groups, use parentheses () to group and $1, $2, $3, $n to replace.

Here is an example.

Before:

This is the text before the replace.

After:

This is the text after the replace.

Leave a Comment