How to do math inside of a regex?

R

Rossman123

If I have "Tom owns 2 cats", how do I search and replace with a regex,
so that I get "Tom owns 3 cats" ? I want to be able to find a digit,
add 1 to the digit, and replace with the result. Thanks!
 
B

Brian Wakem

Rossman123 said:
If I have "Tom owns 2 cats", how do I search and replace with a regex,
so that I get "Tom owns 3 cats" ? I want to be able to find a digit,
add 1 to the digit, and replace with the result. Thanks!


s#(\d)#$1+1#e
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,284
Messages
2,571,413
Members
48,106
Latest member
JamisonDev

Latest Threads

Top