How to match and replace text with integer and change text but not the integer?

I want to match lastBid = \d where \d is integer and add next line below lastBid = \d with randomText but not change the integer

For example:

lastBid = 3 to

lastBid = 3
randomText

How can I do it? If I can't maybe there is other way to do it (not in Android Studio)?


Solution 1:

You can use parens () for grouping. I think referencing a group in android studio would be $n where n is the captured group number.

So try find: (lastBid = \d) replace with: $1\nrandomtext