Tommy do Nascimiento
Tommy do Nascimiento

Reputation: 157

Using regular expresion in vscode to change some code

I editing a latex document where I want to change the references from \ref{eq:6.3.78} to (\ref{eq:6.3.78})

I tried to match first all the strings like \ref{SOMETHING} with \ref{.\*} and then change to (\ref{.\*}) but this don't work. Why? Or how can archive this.

Manually it would take me more than 10 hours since is a complete math book.

Upvotes: 1

Views: 54

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521289

You need to escape both the backslash and the curly braces. Try the following find and replace, in regex mode:

Find:    \\ref\{[^}]+\}
Replace: ($0)

Demo

If for some reason the above does not work with VSCode, then you may try explicitly capturing the entire pattern:

Find:    (\\ref\{[^}]+\})
Replace: ($1)

Note: If $1 does not work, then try using \\1 instead.

Upvotes: 2

Related Questions