I have 100s of files which contains the following code:
color: $variable
I wish to replace all of them to
color: var(--variable)
So, essentially, replacing $
with var(-- )
. How do I accomplish this?
CodePudding user response:
Here is one way to do so:
Find:
(?<=color: )\$(. )
Replace with:
var(--$1)
(?<=)
: Positive lookbehind.color:
: Matchescolor:
.\$
: Matches$
.(. )
: Matches any character except new lines, between one and unlimited times, as much as possible.
$1
is the first capture group (first match in parentheses).
CodePudding user response:
Capture the parts you want to keep then put them back using back references:
Find: color: \$(\w )
Replace: color: var(--$1)