S
S
sellerr2015-12-15 22:48:41
Regular Expressions
sellerr, 2015-12-15 22:48:41

Regular expressions. How to find a number and add to it?

Please help.
There is a line of the form It is <img src="/d/349846-2/
necessary to replace 349846, namely, add +2 to this number .
It should turn out <img src="/d/349848-2/
Thank you in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DevMan, 2015-12-16
@sellerr

ideone.com/DltVvA
www.php.net/preg_replace_callback

S
sellerr, 2015-12-15
@sellerr

Something with the encoding turned out to be wrong in the question.
There is a line like <img src="/d/349822-2/
you need to replace the number 349822 and add + 2 to it, it
should work <img src="/d/349824-2/for an example. Use in php script.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question