Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Jul 2001
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Wildcard Replace (97 SR2)

    I've just started investigating the rather wonderful things that can be done with wildcards in Search/Replace, and it seems that there should be a way of replacing European-style dates (day/month/year) by US-style dates (month/day/year) when in numbers, e.g. 25/12/00 becomes 12/25/00.
    Any ideas? Thx - Isabel

  2. #2
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Wildcard Replace (97 SR2)

    Hi Isabel,

    This should work:
    Find what: ([0-9]@/)([0-9]@/)([0-9]@)
    Replace with: 213

    If you want to transpose from 19.10.2001 to 10/19/2001:
    Find what: ([0-9]@).([0-9]@).([0-9]@)
    Replace with: 2/1/3

    The trick is to put round brackets/parentheses () around everything you want to reuse in the replacement text.

    [0-9]@ will match any number of digits. You could use [0-9]{1,2} for days/months and [0-9]{2,4} for years instead to make sure only "proper" dates are matched.

    <A target="_blank" HREF=http://www.mvps.org/word/FAQs/General/UsingWildcards.htm>This article on wildcards</A> has some more tipps in chapter "Example 2: Transposing dates".

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>Greetings, Klaus

  3. #3
    Lounger
    Join Date
    Jul 2001
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Wildcard Replace (97 SR2)

    Hi, Klaus. That is so clever, and it works beautifully. I read the article you co-authored with great interest. It was written with admirable clarity; even I could follow it <g>. Two-thirds of the way down, anyhow.

    I tried an application of my own but it didn't work.
    Problem: to capitalize the first letter of a sentence (Word does it automatically...most of the time).
    My attempt: Find . [a-z] (that's: period/space/[a-z]
    Replace by: . [A-Z] (that's: period/space/[A-Z].
    It finds the right things, but replaces, for example,
    . the, by
    . [A-Z]he, rather than "the same letter, capitalized" as intended.
    Is there a syntax for what I'm looking for?

    Many thanks - Isabel

  4. #4
    Lounger
    Join Date
    Jul 2001
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Wildcard Replace (97 SR2)

    Hi, Klaus. Me again. Wondering if something in your bag of tricks will tidy up ill-formatted incoming e-mails that don't wrap properly. Easy enough to get rid of all the pointed brackets (<<) in the left margin, and replace a string of spaces by one space, but one would also like to replace the line end character, whatever it is, by a space.

    By the way, your article solved another problem of mine which is that ^l does not find a paragraph mark on my computer. (All the other caret+letter special formatting characters work.) Your article says to use ^13, which works just fine. I refrain from asking why; I merely remain humbly grateful <g>.

    Isabel

  5. #5
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Wildcard Replace (97 SR2)

    Hi Isabel,

    >> Two-thirds of the way down, anyhow.

    I fear the last third was my contribution <img src=/S/grin.gif border=0 alt=grin width=15 height=15>. Most work was done by Graham Mayor; Dave Rado suggested the article and did a great editing job.

    >> ((replacing [a-z] with [A-Z]))

    You cannot use any of the special wildcards in replacement text, except for 1, 2, ...
    Word wildcard searches know nothing about lower and upper case, so they can't be much help in capitalizing words. There are some clever macro approaches to do what you want, but it is hard to find where a sentence really ends (with abbreviations, "..." etc.).

    Some neat tricks that help you to clean up e-mails can be found in <A target="_blank" HREF=http://www.mvps.org/word/FAQs/Formatting/CleanWebText.htm>this article by Suzanne S. Barnhill and Dave Rado</A>.

    I don't know why you have to use ^13 instead of ^p in wildcard searches, either. Yesterday, I <A target="_blank" HREF=http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Cat=&Board=wrd&Number=84353&page=0 &view=collapsed&sb=5&o=0&vc=1#Post84353>asked Microsoft</A> if they could include anchors for paragraphs (like < and > for words).

    Hope you have lots of fun playing with wildcards,

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>Klaus

  6. #6
    Lounger
    Join Date
    Jul 2001
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Wildcard Replace (97 SR2)

    Hi, Klaus. So the last third of the article was you; I should have guessed. <img src=/S/clever.gif border=0 alt=clever width=15 height=15>

    Thanks much for the reference to the cleaning up article. I've passed it on to my listserve group, many of whom forward messages enthusiastically and raggedly. I didn't know the MS website had such useful stuff; I wasted a perfectly good Saturday morning reading it <img src=/S/crazy.gif border=0 alt=crazy width=15 height=15>. All grist to the mill.

    Isabel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •