[duxuser] a wild time with wild cards: solving blank indicator and dotted phone numbers with ease

  • From: "Dean Martineau" <dean@xxxxxxxxxxxxxxxxxxxxx>
  • To: <duxuser@xxxxxxxxxxxxx>
  • Date: Tue, 8 Jul 2008 18:14:41 -0700

Thanks to everybody for your answers to my recent questions.  It was good to
hear from Betsy again after some time.
 
Brett and I are thinking alike.  This thread has prompted me to dig back
into Word?s underdocumented and somewhat inferior wild card implementation,
which despite its weakness relative to that of other programs still can
solve lots of problems.  I love wild cards!  Hopefully some of you will
catch the bug.
 
To begin, let?s replace all occurrences of at least three underline
characters with a string of four dashes.  As Brett indicated, what you
replace them with is entirely up to you. 
 
In Word?s ctrl+h Replace dialog, first hit alt+m to click the more button
and expand the dialog, then alt+u to check the box to use wild cards. Now,
in the Find box, enter this: _{3,}
 
That means the underline character, occurring at least three times.  
 
The replace string contains the string of your choice, in my case, four
dashes.
 
Hit alt+a for replace all.  Voilà.
 
Now for the phone number problem, where people are using periods instead of
dashes.  This is long, but it works based on my test.  To explain:
parentheses mark a string you want to retain when you replace the text;
brackets denote a character class for the find string; and braces are used
to count occurrences.  With this in mind, we define a character string
consisting of digits, we want to find any situation where three digits, then
a period, then four more digits, and replace that string with the identical
digits, a dash, and the last four identical digits.   The find string looks
like this: 
 
([0-9]{3}).([0-9]{4})
 
In the replacement string, any string surrounded by parentheses takes on a
number, and we use the backslash to mark those strings to preserve.  So the
replacement string for our example consists of \1-\2
 
I suspect a lot of other document cleanup can be done in Word using wild
cards.
 
I hope this is helpful to others.
 
Dean
 

Other related posts:

  • » [duxuser] a wild time with wild cards: solving blank indicator and dotted phone numbers with ease