Find and Replace

Feature requests, and in-depth discussions of features and the way Mellel works

Moderators: Eyal Redler, redlers, Ori Redler

Post Reply
rbkopelman
New to all this
Posts: 3
Joined: Fri Jan 26, 2018 12:50 am

Find and Replace

Post by rbkopelman »

For Find & Replace Mavins: Is there a way to increment a number in a replace operation. What I am trying to do is find all instances of a pattern, say "bug". This is easy enough to do with a find operation. I wish to replace each instance of the word "bug" by tagging it with which instance it is. Thus, for the 1st match, "bug" is replaced by "bug1" the second match is replaced by "bug2" and so on. Then I could use replace all & run this & it would be done in a jiffy. Does anyone know if this is possible & what magic might make it happen? Is it possible to do this with a regex?

Ronald B. Kopelman
Icelander
Knows everything, can prove it
Posts: 378
Joined: Mon Aug 18, 2014 10:59 pm

Re: Find and Replace

Post by Icelander »

This is a nice question, and
this is how you can do it:

1. Create a new Auto-title and name it “Incremental Number”


Image

2. The value must be Level#
Image

3. Enter “bug” in the Find box and “Found Expression” in the Replace box. Then click on the down-arrow on the left side of the Replace box and select “Insert Auto-title”

Image

4. You will see this
Image

5. Choose “Incremental Number” from the dropdown-menu.


Image


6. The Replace box should now look like this:


Image


7. Click “Replace All” and you should instantly get something like this; I used a red color so the parts that were replaced stand out:


Image
Last edited by Icelander on Sun Jul 21, 2024 7:48 pm, edited 2 times in total.
rbkopelman
New to all this
Posts: 3
Joined: Fri Jan 26, 2018 12:50 am

Re: Find and Replace

Post by rbkopelman »

Icelander: Thank you! I will try this. I never would have thought of this. It will come in very handy!
Post Reply