Home Download Buy Blog Forum Support

regex replace with math

regex replace with math

Postby Lirave on Fri Sep 20, 2013 3:01 pm

Hi i want to know if it is possible to replace text with regex and do some math operation.

x10 y10 -> xy20

I would search this with
x(..) y(..)

and replace it with ?

xy($1+$2) ? (don't know what operation to use)
Posts: 1
Joined: Sun Jun 16, 2013 8:47 am

Re: regex replace with math

Postby adzenith on Fri Sep 20, 2013 3:50 pm

Regular expressions can't do this. However, many languages' regex libraries (such as Python's) have the ability to pipe the replacement through a function. You could write a plugin.
Posts: 1403
Joined: Mon Oct 19, 2009 9:12 pm

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 26 guests