F/R with Wildcards

S

Steve

Can I use an expression in a Replacement.Text? Here's what I want to do:

.Text = "([0-9]{1,})<space>([Mm])" ' "<space>" is
an actual space
.Replacement.Text = "\1^s" & UCase("\2")

I want to find any number followed by a space and an "M" or "m", then
replace it with the same number, a non-breaking space and an upper case "M".

I can't get this to work. Is there another way to do this if I can't use the
calculated expression?

Steve
 
S

Steve

Clarification...obviously I can set .Replacement.Text = "\1^sM\2".
I forgot to mention that I really want to search for ([BbMm]) and replace
with "B" or "M", hence the need to use uCase.
 
S

Steve

Helmut...thanks. That is strange. It won't do the upper case conversion of
b->B and m->M for me. It's converting the space to a non-breaking space OK.
You're sure it's working?

Running Office2000/Word 2000 running on Win2000.
Steve

Sub Test()
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting

With Selection.Find
.Text = "([0-9]{1,}) ([BbMm])([ ,.^13])"
.Replacement.Text = "\1^s" & UCase("\2") & "\3"
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
 
H

Helmut Weber

Hi Steve,
no, I am not sure anymore. Maybe I was puzzled
because I didn't receive an error.
But I am on a different machine now.
Here no conversion is done and I guess it never was.
Didn't see something like Ucase in a wildcard
search before. Maybe somebody else will
know better.
 
S

Steve

OK. In the meantime, I've got two blocks. One changes [Mm] to "M" and the
other changes [Bb] to "B". Thanks.

Steve
 
W

Word Heretic

G'day "Steve" <[email protected]>,

You have to turn .MatchWildcards on

Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


Steve reckoned:
Clarification...obviously I can set .Replacement.Text = "\1^sM\2".
I forgot to mention that I really want to search for ([BbMm]) and replace
with "B" or "M", hence the need to use uCase.


Steve said:
Can I use an expression in a Replacement.Text? Here's what I want to do:

.Text = "([0-9]{1,})<space>([Mm])" ' "<space>" is
an actual space
.Replacement.Text = "\1^s" & UCase("\2")

I want to find any number followed by a space and an "M" or "m", then
replace it with the same number, a non-breaking space and an upper case "M".

I can't get this to work. Is there another way to do this if I can't use the
calculated expression?

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top