Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Wildcard problem with ordinals
Is there any way to do a wildcard search that strips out ordinals from dates (e.g. "19th September 2007" - "19 September 2007", "March 21st, 2007" - "March 21, 2007") but does *not* strip out ordinals from anything that is not a date (e.g. leaves "19th century" alone)?
I was using the search string: ([1-9]{1,})([a-z]{2}) and replace string "\1" until I discovered it was stripping the ordinal from things like 19th century, which I don't want it to do. Dave |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Wildcard problem with ordinals
Not a single search with so many variables.
-- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Dave Logan wrote: Is there any way to do a wildcard search that strips out ordinals from dates (e.g. "19th September 2007" - "19 September 2007", "March 21st, 2007" - "March 21, 2007") but does *not* strip out ordinals from anything that is not a date (e.g. leaves "19th century" alone)? I was using the search string: ([1-9]{1,})([a-z]{2}) and replace string "\1" until I discovered it was stripping the ordinal from things like 19th century, which I don't want it to do. Dave |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Wildcard problem with ordinals
Is it possible with two searches? :-)
Dave "Graham Mayor" wrote in message ... | Not a single search with so many variables. | | -- | | Graham Mayor - Word MVP | | My web site www.gmayor.com | Word MVP web site http://word.mvps.org | | | Dave Logan wrote: | Is there any way to do a wildcard search that strips out ordinals | from dates (e.g. "19th September 2007" - "19 September 2007", "March | 21st, 2007" - "March 21, 2007") but does *not* strip out ordinals | from anything that is not a date (e.g. leaves "19th century" alone)? | | I was using the search string: | ([1-9]{1,})([a-z]{2}) | and replace string | "\1" | until I discovered it was stripping the ordinal from things like 19th | century, which I don't want it to do. | | Dave | | |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Wildcard problem with ordinals
The following macro http://www.gmayor.com/installing_macro.htm should remove
all date ordinals using common UK or US date patterns without affecting non-date ordinals Sub RemoveDateOrdinals() Dim vFindText As Variant Dim vReplText As Variant Dim i As Long vFindText = Array("([0-9]{1,2})[dhnrst]{2}([ ,]{1,2}Jan)", _ "([0-9]{1,2})[dhnrst]{2}([ ,]{1,2}Feb)", _ "([0-9]{1,2})[dhnrst]{2}([ ,]{1,2}Mar)", _ "([0-9]{1,2})[dhnrst]{2}([ ,]{1,2}Apr)", _ "([0-9]{1,2})[dhnrst]{2}([ ,]{1,2}May)", _ "([0-9]{1,2})[dhnrst]{2}([ ,]{1,2}Jun)", _ "([0-9]{1,2})[dhnrst]{2}([ ,]{1,2}Jul)", _ "([0-9]{1,2})[dhnrst]{2}([ ,]{1,2}Aug)", _ "([0-9]{1,2})[dhnrst]{2}([ ,]{1,2}Sep)", _ "([0-9]{1,2})[dhnrst]{2}([ ,]{1,2}Oct)", _ "([0-9]{1,2})[dhnrst]{2}([ ,]{1,2}Nov)", _ "([0-9]{1,2})[dhnrst]{2}([ ,]{1,2}Dec)", _ "([0-9]{1,2})[dhnrst]{2}([ ,]{1,2}[0-9]{2,4})") vReplText = "\1\2" With Selection.Find .Forward = True .Wrap = wdFindContinue .MatchWholeWord = True .MatchWildcards = True .MatchSoundsLike = False .MatchAllWordForms = False .Format = True For i = LBound(vFindText) To UBound(vFindText) .Text = vFindText(i) .Replacement.Text = vReplText .Execute replace:=wdReplaceAll Next i End With End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Dave Logan wrote: Is it possible with two searches? :-) Dave "Graham Mayor" wrote in message ... Not a single search with so many variables. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Dave Logan wrote: Is there any way to do a wildcard search that strips out ordinals from dates (e.g. "19th September 2007" - "19 September 2007", "March 21st, 2007" - "March 21, 2007") but does *not* strip out ordinals from anything that is not a date (e.g. leaves "19th century" alone)? I was using the search string: ([1-9]{1,})([a-z]{2}) and replace string "\1" until I discovered it was stripping the ordinal from things like 19th century, which I don't want it to do. Dave |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
A wildcard question | Microsoft Word Help | |||
Wildcard search help. please? | Microsoft Word Help | |||
Superscripting Ordinals that are not Superscripted | Microsoft Word Help | |||
Date Fields -making ordinals superscript | Microsoft Word Help | |||
Using a Wildcard | Microsoft Word Help |