Sublime Forum

[Solved] How to replace straight quotes into curly quotes with regular expression

#1

With regular expression I am trying to replace text within straight quotes into curly quotes. I use: '[^"]*' or '[a-z]*' to individually search single quoted text. But how do I maintain the text while replacing the straight quotes into curly ones? I used replace with ‘$1’ and ‘$&’ but without the desired result.

0 Likes

#2

you need to use capture groups if you want to use some of the captured text in a replace expression. Capture groups are those in parenthesis, and are numbered starting from 1 (capture group 0 is always the whole match).

try

Find: '([^']*)'
Replace: ‘$1’

2 Likes

#4

sorry, I messed up the placement of the closing paren and the star - I’ve now edited my post to correct it. Please can you try again.

0 Likes

#5

Many thanks! That worked :slightly_smiling:

0 Likes