Re: Distinguishing hard spaces from regular spaces

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi John,

Just change to .MatchWildcards = True.

A wildcard search using a space character in the Find.Text expression won't
match a nonbreaking space. Everything else remains the same. See
http://www.gmayor.com/replace_using_wildcards.htm for more about wildcards.
The article does note that wildcard searches are case-sensitive, but this
little tidbit is missing.

A warning to anyone who's about to suggest using a wildcard Find.Text
expression of " ([;:\!\?]) to catch all the punctuation in one execution,
and a Replacement.Text expression of " \1" -- I tried it, and it doesn't
work. There's a bug that reverses the replacement when you use the \1 code,
so space+punctuation is replaced by punctuation+nonbreaking space. I first
ran into that bug in Word 2007 Beta 1, but it's also in Word 2003 and
probably earlier versions.

--
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.

John Doue wrote:
Hi,

Since in French, characters (;:?!) need an unbreakable space before
them, I frequnetly run a routine like this one for each of them:

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = " ;"
.Replacement.Text = "^s;"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.Mat chWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll

which gets the job done.

However, I was recently remarked by a fellow translator that the
revised translations I was returning to him (with track changes on
screen) showed that all the properly hardspaced characters he had
inserted had been replaced by ... properly hardspaced characters.

Looking into the issue, I realized (I had forgotten about this) that
Word considers a "hard space" also as a "space" ... and therefore, my
macro needlessly replaces them. Which shows on screen when tracking
changes in on while running the macro.

Any ideas how to work around this?

Best regards


.



Relevant Pages

  • Re: CONTAINS and non-wildcard asterisk
    ... >> wildcard it, and you wrap it in single quotes. ... >> If you wrap the phrase with double quotes you will get wildcarding, but it>> will still match with test*. ... >> alphanumeric characters it strips them out and indexes the alphanumeric ... >> Looking for a book on SQL Server replication? ...
    (microsoft.public.sqlserver.fulltext)
  • Optimal wildcard search algorithm
    ... whether or not one or more users exist, given some wildcard expression. ... but we'll focus on username brute-forcing for this ... One approach to finding all usernames would be a kind of breadth-first ... and determine which characters exist in the first position. ...
    (Pen-Test)
  • Re: Census ennumeration districts
    ... You searched for Blanche Jones 24 hits ... The wildcard query resulted in too many matches. ... Use more characters before the wildcard. ...
    (soc.genealogy.britain)
  • Re: find/replace in table colum
    ... > nancypennell wrote: ... Contrary to the wildcard *, which stops matching as soon as possible (in ... Graham's wildcard search after the first word), is "greedy" and ... But it has some built-in limitations (I think, it matches 255 characters at ...
    (microsoft.public.word.docmanagement)
  • RE: remove last three characters of cell
    ... "Ray A" wrote: ... I am trying to use the same formula to remove the last three characters ... >> specify the letter as a wildcard, ... If it is not a comma then will just return the entire ...
    (microsoft.public.excel.misc)