Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.newusers
|
|||
|
|||
find and replace using wildcard characters
How do I do a search and replace using wildcard characters? I know that I
have to select Use wildcards in the search and replace dialog window. For instance I want to replace all instances of words enclosed using single quotes with double quotes. I put the following in the find entry field: '*'. Word retrieves the words in single quotes, but when I try to replace it with the following in the replace entry field "*", it replaces the string with exactly that ("*"). I don't know how to make the replace use the wildcard characters as well. |
#2
Posted to microsoft.public.word.newusers
|
|||
|
|||
find and replace using wildcard characters
"fjfvan" wrote:
How do I do a search and replace using wildcard characters? I know that I have to select Use wildcards in the search and replace dialog window. For instance I want to replace all instances of words enclosed using single quotes with double quotes. I put the following in the find entry field: '*'. Word retrieves the words in single quotes, but when I try to replace it with the following in the replace entry field "*", it replaces the string with exactly that ("*"). I don't know how to make the replace use the wildcard characters as well. You have a couple of things right, but it does not quite fit together yet... * does match any text, and since you want to match anything between single quotes, that's a good start. You can put stuff in (parentheses) so that you can then re-use those sub-expressions within the (parentheses) in "Replace with", and throw away stuff that is outside. So you might use Find what: '(*)' What's missing is how to re-use the stuff in the bracket in "Replace with"... That is done with \1 ... So you could use Replace with: "\1" For safety, I'd use say Find what: '(*)' That introduces the jokers and which only match text at the beginning and at the end of a word. The reason: Apostrophes appear all over the place in English, so it makes sense to lower the changes you match something that is not actually a quote. For the same reason, I avoid the * wildcard as too risky, and use say [!^13]@ instead, which matches any text too, but never matches across paragraphs (... ^13 being the code of the paragraph mark). For figuring out the above, and for more info, see for example http://word.mvps.org/faQs/General/UsingWildcards.htm But above that, experiment whenever you have something that looks like it might be done better with a wildcard replacement. Regards, Klaus |
#3
Posted to microsoft.public.word.newusers
|
|||
|
|||
find and replace using wildcard characters
Dear Klaus:
Thank you so much! You are a lifesaver. This helped enormously. FF "Klaus Linke" wrote: "fjfvan" wrote: How do I do a search and replace using wildcard characters? I know that I have to select Use wildcards in the search and replace dialog window. For instance I want to replace all instances of words enclosed using single quotes with double quotes. I put the following in the find entry field: '*'. Word retrieves the words in single quotes, but when I try to replace it with the following in the replace entry field "*", it replaces the string with exactly that ("*"). I don't know how to make the replace use the wildcard characters as well. You have a couple of things right, but it does not quite fit together yet... * does match any text, and since you want to match anything between single quotes, that's a good start. You can put stuff in (parentheses) so that you can then re-use those sub-expressions within the (parentheses) in "Replace with", and throw away stuff that is outside. So you might use Find what: '(*)' What's missing is how to re-use the stuff in the bracket in "Replace with"... That is done with \1 ... So you could use Replace with: "\1" For safety, I'd use say Find what: '(*)' That introduces the jokers and which only match text at the beginning and at the end of a word. The reason: Apostrophes appear all over the place in English, so it makes sense to lower the changes you match something that is not actually a quote. For the same reason, I avoid the * wildcard as too risky, and use say [!^13]@ instead, which matches any text too, but never matches across paragraphs (... ^13 being the code of the paragraph mark). For figuring out the above, and for more info, see for example http://word.mvps.org/faQs/General/UsingWildcards.htm But above that, experiment whenever you have something that looks like it might be done better with a wildcard replacement. Regards, Klaus |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Wildcard replacement of characters and style | Microsoft Word Help | |||
Find & Replace Wildcard Expression for Ordinal Numbers | Microsoft Word Help | |||
Find multiple characters in one find using MSword find/replace | Microsoft Word Help | |||
Help with Wildcard search/replace, please? | Microsoft Word Help | |||
Bizarre wildcard replace | Microsoft Word Help |