View Full Version : Wordlists – Find/Replace Within Each Paragraph Separately
VB-AN-IZ
10-28-2018, 11:27 PM
I use find/replace a lot with wordlists. The wordlists generally contain one word/phrase within each paragraph. I'm trying to create a macro that will:
Find/replace text within each paragraph separately.
If it finds "}" (for example) within a paragraph, it'll replace with a tab, then move to the next paragraph.
If "}" is not found within a paragraph, it'll move to the next paragraph and find again.
Relatedly, I would potentially try to find/replace from the start of a paragraph up to the "}" character, but not beyond that character within each paragraph. Is there a simple way to do that?
Appreciate any help!
macropod
10-29-2018, 12:09 AM
Except for the mention of wordlists, there is nothing about what you've described to suggest either that a macro is required or that paragraphs, as such, are a relevant consideration. For what you've described, a simple Find/Replace with:
Find = }
Replace = ^t
would do.
As for word list processing, I've previously provided you with code to do just that. This kind of thing has already been discussed and resolved in many other threads, too. Instead of expecting to be spoon-fed solutions for each new problem, you should make some effort to learn from what you've already been provided and from the other resources available from this forum. Do that and, if you get stuck, post back with the relevant code and we'll happily provide more guidance.
VB-AN-IZ
10-29-2018, 02:46 AM
Apologies for providing a meaningless example. The purpose I'm thinking of currently is to move to the next paragraph after the first successful find/replace within each paragraph. So, based on my original example, assume there are multiple } characters within several of the paragraphs, and that I only want to find/replace the first one in each paragraph.
macropod
10-29-2018, 03:03 AM
Even that only requires a fairly straightforward wildcard Find/Replace, where:
Find = \}(*^13)
Replace = ^t\1
VB-AN-IZ
10-29-2018, 09:47 PM
Say I want to replace all the "A" characters before, but not after, the "}" character within each paragraph. If there's no "A" before the "}" character in a paragraph, but there is one after the "}" character, finding/replacing "\}(*^13)" will modify the text after the "}" character on one paragraph until the end of the following paragraph.
macropod
10-29-2018, 10:38 PM
You really should spend a bit of time learning the wildcard syntax. As it is, it's not apparent to me whether you want to process all A} sets (in which case you might use Find = A\}) or just the first one (in which case you might use Find = A\}(*^13)); neither is it apparent what you want to do with those A characters.
VB-AN-IZ
11-05-2018, 05:31 AM
I'm familiar with the wildcard syntax. All the examples you've provided effectively do the same thing – if it finds an "A" after the "}" character but not before it, it'll find text out of sequence from that point in the document.
I want to find/replace the "A" characters before the "}" character within each paragraph; if there isn't an "A" character before the "}" character in each paragraph, I want to stop the find process at the "}" character and restart it from the start of the next paragraph. So, searching only between the start of a paragraph and the "}" character.
macropod
11-05-2018, 01:43 PM
All the examples you've provided effectively do the same thing – if it finds an "A" after the "}" character but not before it, it'll find text out of sequence from that point in the document.Unless you're starting the Find with the insertion point after the first A} sequence in a paragraph, that simply isn't so. You could confirm that by doing a wildcard Find/Replace where:
Find = A\}(*^13)
Replace = X\1
I want to find/replace the "A" characters before the "}" character within each paragraph; if there isn't an "A" character before the "}" character in each paragraph, I want to stop the find process at the "}" character and restart it from the start of the next paragraph. So, searching only between the start of a paragraph and the "}" character.
Unless you're now saying that if there's a } before the first A} you want to skip the entire paragraph - which is a completely different proposition from what you previously said - the expression I gave you already does that if you don't
start the Find with the insertion point after the first A} sequence in a paragraph.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.