So, I wanna create a snippet that turns e.g. rgba(102,83,47,1)
type strings into 102 83 47
.
I already wrote a working RegEx expression:
regexr.com/7mo33
(?:rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),.*)
Which returns the RGB values into three capture groups.
But my VCS snippet doesn't seem to be working:
"Vic3araxRGBpickertoPDX": {
"prefix": [
"RGB Picker to Clausewitz"
],
"body": [
"${TM_SELECTED_TEXT/rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),.*/$1 $2 $3/}"
],
"description": "Removes the rgb() and turns commas into space"
},
It's simply returning ${TM_SELECTED_TEXT/rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),.*/ /}
My best guess is that the quantifier brackets at \d{1,3}
mess with the variable transformer, but I have no idea.
Btw. I'm not married to that RegEx expression, so if there's a better way to do it, I wouldn't mind.
Change your body
property to
"body": [
"${TM_SELECTED_TEXT/rgba\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3}),.*\\)/$1 $2 $3/}"
],