Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Dave Logan Dave Logan is offline
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Dave Logan Dave Logan is offline
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
A wildcard question jezzica85 Microsoft Word Help 2 October 24th 06 07:12 AM
Wildcard search help. please? Ed Microsoft Word Help 2 September 11th 06 08:50 PM
Superscripting Ordinals that are not Superscripted Josh Microsoft Word Help 4 May 13th 06 08:24 PM
Date Fields -making ordinals superscript Tim Baker Microsoft Word Help 4 September 7th 05 09:34 AM
Using a Wildcard Steved Microsoft Word Help 4 May 30th 05 08:33 PM


All times are GMT +1. The time now is 08:24 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"