Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Finding a single word via find/replace wildcards
Hi, I'm running Word '03 on WinXP sp3.
I'm trying to catch the word "wouldest" in a multiword selection and convert it to "would". I've got the find/replace dialog open, wildcards checked, all other options cleared, but this Find string: (*)[! ]dest is pulling in the entire selection up to and including the word "wouldest". If I hit Next the selection recedes by one word at its beginning. The way I see it, the [! ] should kill finding multiple words, since the space is not allowed. Do I have that right? I must be doing something wrong. Any input would be appreciated. p. |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Finding a single word via find/replace wildcards
Sorry, you don't have it right. The [! ] in that expression means only
that the single character preceding "dest" must not be a space; but it doesn't restrict any of the characters that come before that. The real cause of your problem, though, is the asterisk. That will match as many characters as possible, including spaces and even paragraph marks. For the task as stated, I don't quite understand why you're using wildcards -- you should be able to search for the specific word "wouldest" and replace it with "would". But if you do want to use wildcards, I'll suggest either of these search terms: [! ]@dest [A-Za-z]@dest The difference is mainly that the first one would match digits and punctuation marks as well as letters. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. On Tue, 15 Jun 2010 04:28:06 -0700 (PDT), "Paul B." wrote: Hi, I'm running Word '03 on WinXP sp3. I'm trying to catch the word "wouldest" in a multiword selection and convert it to "would". I've got the find/replace dialog open, wildcards checked, all other options cleared, but this Find string: (*)[! ]dest is pulling in the entire selection up to and including the word "wouldest". If I hit Next the selection recedes by one word at its beginning. The way I see it, the [! ] should kill finding multiple words, since the space is not allowed. Do I have that right? I must be doing something wrong. Any input would be appreciated. p. |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Finding a single word via find/replace wildcards
I think it might help to clarify what it means to 'catch the word
"wouldest" in a multiword selection'. Selection means something very specific in windows environments. Do you mean instead that you want to match all instances of "wouldest" occuring within a specific pattern of words? A few simple examples would help. On Jun 15, 8:26*am, Jay Freedman wrote: Sorry, you don't have it right. The [! ] in that expression means only that the single character preceding "dest" must not be a space; but it doesn't restrict any of the characters that come before that. The real cause of your problem, though, is the asterisk. That will match as many characters as possible, including spaces and even paragraph marks. For the task as stated, I don't quite understand why you're using wildcards -- you should be able to search for the specific word "wouldest" and replace it with "would". But if you do want to use wildcards, I'll suggest either of these search terms: [! ]@dest [A-Za-z]@dest The difference is mainly that the first one would match digits and punctuation marks as well as letters. On Tue, 15 Jun 2010 04:28:06 -0700 (PDT), "Paul B." wrote: Hi, I'm running Word '03 on WinXP sp3. I'm trying to catch the word "wouldest" in a multiword selection and convert it to "would". I've got the find/replace dialog open, wildcards checked, all other options cleared, but this Find string: (*)[! ]dest is pulling in the entire selection up to and including the word "wouldest". If I hit Next the selection recedes by one word at its beginning. The way I see it, the [! ] should kill finding multiple words, since the space is not allowed. Do I have that right? I must be doing something wrong. Any input would be appreciated. p. |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Finding a single word via find/replace wildcards
Given that there is no such word as 'wouldest' in the spelling dictionary, I
would have thought that the spell check could have taken care of this? F7 -change all? |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Finding a single word via find/replace wildcards
Spaces are allowed within the "*" bit. You are looking for the anything
starting at the beginning of a word (*) followed by a single non-space ([! ]) followed by "dest" at the end of a word. You have found a whole string of stuff followed by "l" (a non-space) followed by "dest". I don't see why you can't just look for wouldest, but what you need to do to the search string you have is make it look for a sequence of non-space characters ... [! ]@dest -- Enjoy, Tony www.WordArticles.com "Paul B." wrote in message ... Hi, I'm running Word '03 on WinXP sp3. I'm trying to catch the word "wouldest" in a multiword selection and convert it to "would". I've got the find/replace dialog open, wildcards checked, all other options cleared, but this Find string: (*)[! ]dest is pulling in the entire selection up to and including the word "wouldest". If I hit Next the selection recedes by one word at its beginning. The way I see it, the [! ] should kill finding multiple words, since the space is not allowed. Do I have that right? I must be doing something wrong. Any input would be appreciated. p. |
#6
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Finding a single word via find/replace wildcards
Ignore me! I saw the original post and replied without registering that Jay
had already given virtually the same answer. -- Enjoy, Tony www.WordArticles.com "Tony Jollans" wrote in message ... Spaces are allowed within the "*" bit. You are looking for the anything starting at the beginning of a word (*) followed by a single non-space ([! ]) followed by "dest" at the end of a word. You have found a whole string of stuff followed by "l" (a non-space) followed by "dest". I don't see why you can't just look for wouldest, but what you need to do to the search string you have is make it look for a sequence of non-space characters ... [! ]@dest -- Enjoy, Tony www.WordArticles.com "Paul B." wrote in message ... Hi, I'm running Word '03 on WinXP sp3. I'm trying to catch the word "wouldest" in a multiword selection and convert it to "would". I've got the find/replace dialog open, wildcards checked, all other options cleared, but this Find string: (*)[! ]dest is pulling in the entire selection up to and including the word "wouldest". If I hit Next the selection recedes by one word at its beginning. The way I see it, the [! ] should kill finding multiple words, since the space is not allowed. Do I have that right? I must be doing something wrong. Any input would be appreciated. p. |
#7
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Finding a single word via find/replace wildcards
Thanks to everyone for the answer. That was a very clear explanation,
Jay. The function of the @ had escaped me. I have some Perl RegEx experience, but Word's lingo frequently drives me batty. Graham, the reason I'm trying to do this via Search is that I occasionally want to convert KJV Bible verses to more modern usage, so it's more than a question of the "wouldest" word, and I'm constructing a macro to do it all (besides, I have a KJV dictionary installed, so 'wouldst' isn't flagged in spell check). I could have made that more clear in my post. I'll probably doctor this up to only pick up "est" word endings preceded by certain consonants, in order to avoid false positives. And Tony - sorry, but I refuse to ignore you! Be well, p. On Jun 15, 8:26*am, Jay Freedman wrote: Sorry, you don't have it right. The [! ] in that expression means only that the single character preceding "dest" must not be a space; but it doesn't restrict any of the characters that come before that. The real cause of your problem, though, is the asterisk. That will match as many characters as possible, including spaces and even paragraph marks. For the task as stated, I don't quite understand why you're using wildcards -- you should be able to search for the specific word "wouldest" and replace it with "would". But if you do want to use wildcards, I'll suggest either of these search terms: [! ]@dest [A-Za-z]@dest The difference is mainly that the first one would match digits and punctuation marks as well as letters. -- Regards, Jay Freedman Microsoft Word MVP * * * *FAQ:http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. On Tue, 15 Jun 2010 04:28:06 -0700 (PDT), "Paul B." wrote: Hi, I'm running Word '03 on WinXP sp3. I'm trying to catch the word "wouldest" in a multiword selection and convert it to "would". I've got the find/replace dialog open, wildcards checked, all other options cleared, but this Find string: (*)[! ]dest is pulling in the entire selection up to and including the word "wouldest". If I hit Next the selection recedes by one word at its beginning. The way I see it, the [! ] should kill finding multiple words, since the space is not allowed. Do I have that right? I must be doing something wrong. Any input would be appreciated. p. |
#8
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Finding a single word via find/replace wildcards
You could turn off your KJV dictionary and that would then allow such words
to be flagged as in error and give you the option to replace all with real words. If you want to stick with searches, then http://www.gmayor.com/replace_using_wildcards.htm will explain the structure -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Paul B." wrote in message ... Thanks to everyone for the answer. That was a very clear explanation, Jay. The function of the @ had escaped me. I have some Perl RegEx experience, but Word's lingo frequently drives me batty. Graham, the reason I'm trying to do this via Search is that I occasionally want to convert KJV Bible verses to more modern usage, so it's more than a question of the "wouldest" word, and I'm constructing a macro to do it all (besides, I have a KJV dictionary installed, so 'wouldst' isn't flagged in spell check). I could have made that more clear in my post. I'll probably doctor this up to only pick up "est" word endings preceded by certain consonants, in order to avoid false positives. |
#9
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Finding a single word via find/replace wildcards
Note that a "modern language KJV" has been published -- I don't know
exactly what it's called -- that smooths out the archaic grammatical forms but retains the poetic diction and doesn't correct the mistaken translations, so is there really a need to do this yourself? On Jun 17, 6:50*am, "Paul B." wrote: Thanks to everyone for the answer. That was a very clear explanation, Jay. The function of the @ had escaped me. I have some Perl RegEx experience, but Word's lingo frequently drives me batty. Graham, the reason I'm trying to do this via Search is that I occasionally want to convert KJV Bible verses to more modern usage, so it's more than a question of the "wouldest" word, and I'm constructing a macro to do it all (besides, I have a KJV dictionary installed, so 'wouldst' isn't flagged in spell check). I could have made that more clear in my post. I'll probably doctor this up to only pick up "est" word endings preceded by certain consonants, in order to avoid false positives. And Tony - sorry, but I refuse to ignore you! Be well, p. On Jun 15, 8:26*am, Jay Freedman wrote: Sorry, you don't have it right. The [! ] in that expression means only that the single character preceding "dest" must not be a space; but it doesn't restrict any of the characters that come before that. The real cause of your problem, though, is the asterisk. That will match as many characters as possible, including spaces and even paragraph marks. For the task as stated, I don't quite understand why you're using wildcards -- you should be able to search for the specific word "wouldest" and replace it with "would". But if you do want to use wildcards, I'll suggest either of these search terms: [! ]@dest [A-Za-z]@dest The difference is mainly that the first one would match digits and punctuation marks as well as letters. -- Regards, Jay Freedman Microsoft Word MVP * * * *FAQ:http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. On Tue, 15 Jun 2010 04:28:06 -0700 (PDT), "Paul B." wrote: Hi, I'm running Word '03 on WinXP sp3. I'm trying to catch the word "wouldest" in a multiword selection and convert it to "would". I've got the find/replace dialog open, wildcards checked, all other options cleared, but this Find string: (*)[! ]dest is pulling in the entire selection up to and including the word "wouldest". If I hit Next the selection recedes by one word at its beginning. The way I see it, the [! ] should kill finding multiple words, since the space is not allowed. Do I have that right? I must be doing something wrong. Any input would be appreciated. |
#10
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Finding a single word via find/replace wildcards
Peter: Yes, there are many updated KJV versions. I seldom use the KJV,
except that I have it electronically with embedded word definitions. But sometimes I have an article in which the quotes are hard to read, so I decided it would be worth it to make a converter. Graham: Since I'm also converting "thee's and thou's and thy's", there's much more to do. And toggling the KJV dictionary would be a nuisance. Paul: Sorry I missed your post first time through. Thanks for your response. p. On Jun 17, 10:43*am, "Peter T. Daniels" wrote: Note that a "modern language KJV" has been published -- I don't know exactly what it's called -- that smooths out the archaic grammatical forms but retains the poetic diction and doesn't correct the mistaken translations, so is there really a need to do this yourself? |
#11
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Finding a single word via find/replace wildcards
OK I give in on the dictionary
If you have a list of the words you want to change and what you want to change them to, you could add them to a two column table. Put the word to find in the left column and the word to replace in the right column. Save the table as Changes.doc (the name is not important as long as you reflect it and its path in the following macro and it will work fine with docx formats). The macro will replace all the first words with the second words in the current document. Sub ReplaceFromTableList() Dim oChanges As Document, oDoc As Document Dim oTable As Table Dim oRng As Range Dim rFindText As Range, rReplacement As Range Dim i As Long Dim sFname As String 'Change the path to reflect your table document sFname = "D:\My Documents\Test\Changes.doc" Set oDoc = ActiveDocument Set oChanges = Documents.Open(FileName:=sFname, Visible:=False) Set oTable = oChanges.Tables(1) For i = 1 To oTable.Rows.Count Set oRng = oDoc.Range Set rFindText = oTable.Cell(i, 1).Range rFindText.End = rFindText.End - 1 Set rReplacement = oTable.Cell(i, 2).Range rReplacement.End = rReplacement.End - 1 With oRng.Find .ClearFormatting .Replacement.ClearFormatting Do While .Execute(findText:=rFindText, _ MatchWholeWord:=True, _ MatchWildcards:=False, _ Forward:=True, _ Wrap:=wdFindContinue) = True oRng.Text = rReplacement Loop End With Next i oChanges.Close wdDoNotSaveChanges End Sub http://www.gmayor.com/installing_macro.htm "Paul B." wrote in message ... Graham: Since I'm also converting "thee's and thou's and thy's", there's much more to do. And toggling the KJV dictionary would be a nuisance. |
#12
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Finding a single word via find/replace wildcards
Wow, that's an amazing macro. I'm glad to see that such referencing is
possible. I'm frankly not sure which method would be better for me in this case. This is more compact than the separate find/replace routines - I think there are five of them - but I'd have to list words separately rather than use wildcards. I'm going to give this some thought. Is there a way to set oRng to the current Selection? IAC, this is a keeper. Thanks. p. On Jun 18, 1:01*am, "Graham Mayor" wrote: OK I give in on the dictionary If you have a list of the words you want to change and what you want to change them to, you could add them to a two column table. Put the word to find in the left column and the word to replace in the right column. Save the table as Changes.doc (the name is not important as long as you reflect it and its path in the following macro and it will work fine with docx formats). The macro will replace all the first words with the second words in the current document. Sub ReplaceFromTableList() Dim oChanges As Document, oDoc As Document Dim oTable As Table Dim oRng As Range Dim rFindText As Range, rReplacement As Range Dim i As Long Dim sFname As String 'Change the path to reflect your table document sFname = "D:\My Documents\Test\Changes.doc" Set oDoc = ActiveDocument Set oChanges = Documents.Open(FileName:=sFname, Visible:=False) Set oTable = oChanges.Tables(1) For i = 1 To oTable.Rows.Count * * Set oRng = oDoc.Range * * Set rFindText = oTable.Cell(i, 1).Range * * rFindText.End = rFindText.End - 1 * * Set rReplacement = oTable.Cell(i, 2).Range * * rReplacement.End = rReplacement.End - 1 * * With oRng.Find * * * * * * .ClearFormatting * * * * * * .Replacement.ClearFormatting * * * * * * Do While .Execute(findText:=rFindText, _ * * * * * * * * MatchWholeWord:=True, _ * * * * * * * * MatchWildcards:=False, _ * * * * * * * * Forward:=True, _ * * * * * * * * Wrap:=wdFindContinue) = True * * * * * * * * oRng.Text = rReplacement * * * * * * Loop * * End With Next i oChanges.Close wdDoNotSaveChanges End Subhttp://www.gmayor.com/installing_macro.htm |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Word Find/Replace Options - wildcards & formatting changes | Microsoft Word Help | |||
find and replace numbers using wildcards | Microsoft Word Help | |||
Word Bug: Find/Replace wildcards while track changes is turned on is buggy | Microsoft Word Help | |||
Find & Replace--Wildcards | Microsoft Word Help | |||
Find/Replace Wildcards | Microsoft Word Help |