#1
|
|||
|
|||
Wildcard Find and Replace anomaly
I have come across what seems to be a Find and Replace anomaly using wildcards. Trying to replace <period><space> with <period><space><space>. Please note that I do not agree with the current "rule" that there should be just one space after a period.
The Find string is (one space between the parentheses): (.) ([A-Z]) I have also tried: (. )([A-Z]) and also looked for something other than a space after <period><space> (. )([! ]) Using the first Find example above, the Replace string is (two spaces between \1 and \2): \1 \2 Working with the following: One sentence. Another sentence. Find correctly highlights ". A". However, the Replace produces this: One sentence.A nother sentence. (two spaces between "A" and "n") Can anybody tell me what's going on here? |
#2
|
|||
|
|||
There is no anomaly at all!
As a “wild card”, [A-Z] will only match one single uppercase character. Note that trying to locate <period><space> as an end of sentence marker is always a bit of a wild goose chase. There are tons of abbreviations, acronyms, etc., followed by <period><space>. However, you might want to try the following wildcard Find/Replace: Find What: (.^32)([A-Z][a-z]{1,}) Replace With: \1^32\2 |
#3
|
||||
|
||||
You should be able to use a wildcard Find/Replace, where:
Find = (. )([A-Z]) Replace = \1 \2 or: Find = (.) ([A-Z]) Replace = \1 \2 or: Find = (.)( [A-Z]) Replace = \1 \2 Find = (. )([! ]) Replace = \1 \2 and so on. None of these is capable of producing 'One sentence.A nother sentence.' There is also no need to complicate things with extra parameters or escape codes.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#4
|
|||
|
|||
Today it works. I have often used wildcard find and replace successfully, including the situation I described. The day I posted I was getting the erratic results. I spent some time on it before posting, as I was sure I had missed something. All I can say is that I am certain I was doing it as I described, with the result I described, but now it works as expected.
"As a 'wild card', [A-Z] will only match one single uppercase character." That was my intent. I was looking for a period followed by a space followed by any upper case character. The Find highlighted that combination. I realize there are abbreviations and other situations where I would not want the extra space, so I was stepping through the document and replacing as appropriate (except I was sidetracked by the the oddity that appeared that day). I had restarted Word, but got the same result. I didn't try a computer restart, but I should have done so before posting. I have seen oddities appear temporarily with Word and other Office products (and not limited to MS programs). All I can think is that this must have been one of those. Anyhow, thanks for the replies. I appreciate both of you taking time to respond. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
New Find/Replace Wildcard Needed | rsrasc | Word VBA | 2 | 11-11-2014 09:46 AM |
Find/Replace Wildcard Needed | rsrasc | Word VBA | 4 | 11-11-2014 08:28 AM |
Wildcard Find and Replace | Ulodesk | Word | 1 | 06-23-2014 10:26 AM |
Wildcard Find/Replace deletes extra character | Cosmo | Word | 1 | 06-20-2014 08:49 AM |
Need help using WildCard Find & Replace | Cayce | Word | 1 | 06-09-2014 04:17 PM |