Reputation: 2402
Using a general regular expression replacement (for me, I'm doing this through TextMate) is it possible to modify a captured token?
I've essentially got a handful of enums that I want to modify...
CONSTANT get { return 1; }
CONSTANT get { return 2; }
CONSTANT get { return 3; }
What I'd like to do is capture the "return x"...
return [\d]
... but then modify the return value by decrementing by 1
$1-1
Is there anyway to do this purely using regexps?
TIA!
Bob
Upvotes: 1
Views: 68
Reputation: 523364
It can't be done purely using regexes. Arithmetics isn't a capability of regex. You need to write a script.
Upvotes: 1