Wildcard problem

P

Paul B.

I'm almost there on a search expression, but the last step is
confounding me. Here's what I'm looking for:

MY GRACE IS SUFFICIENT FOR YOU 9/47
All Rights Reserved - The Good Way Publishing - 2010 http://www.the-good-way.com

This expression:
MY GRACE[a-zA-Z0-9/ ^13\-:.]{11,122}

Finds this:

MY GRACE IS SUFFICIENT FOR YOU 9/47
All Rights Reserved - The Good Way Publishing - 2010 http://www.the-good-way.com
of person he

So I thought this would be easy to resolve by adding "com" to the end
of my expression:
MY GRACE[a-zA-Z0-9/ ^13\-:.]{11,122}.com

thus limiting the find at that point. But that expression is not found
at all, which totally stumps me. I would appreciate any insight into
this.
I'm in Word 03 on Windows XP.

Thanks,
p.
 
G

Graham Mayor

Depending upon what else is in the document you could search for
MY GRACE *way.com

see http://www.gmayor.com/replace_using_wildcards.htm

or you could use a macro

Dim sFindText As String
Dim r As Range
Dim i As Long
sFindText = "MY GRACE IS SUFFICIENT"
Set r = ActiveDocument.Range
With r.Find
Do While .Execute(findText:=sFindText, Forward:=True) = True
r.End = r.Paragraphs(1).Range.End
r.MoveEnd wdWord, 21
If r.Characters.Last = Chr(32) Then
r.End = r.End - 1
End If
'Do what you want with the found text - r - here e.g.
MsgBox r
r.Collapse wdCollapseEnd
Loop
End With


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
P

Paul B.

Wow, did that nail it! My continuing problem is that I don't know why
my expression ending in '.com' didn't work, or why 'MY GRACE *way.com'
was "non-greedy" in its findings, because many times I've found Word's
expressions to be greedy, capturing even multiple pages.

In any case, this makes the whole thing a lot simpler, and it's what I
will try first next time. Thanks much.

p.

Depending upon what else is in the document you could search for
MY GRACE *way.com

seehttp://www.gmayor.com/replace_using_wildcards.htm

or you could use a macro

Dim sFindText As String
Dim r As Range
Dim i As Long
sFindText = "MY GRACE IS SUFFICIENT"
Set r = ActiveDocument.Range
With r.Find
    Do While .Execute(findText:=sFindText, Forward:=True) = True
        r.End = r.Paragraphs(1).Range.End
        r.MoveEnd wdWord, 21
        If r.Characters.Last = Chr(32) Then
            r.End = r.End - 1
        End If
        'Do what you want with the found text - r - here e.g.
        MsgBox r
        r.Collapse wdCollapseEnd
    Loop
End With

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>




I'm almost there on a search expression, but the last step is
confounding me. Here's what I'm looking for:
MY GRACE IS SUFFICIENT FOR YOU 9/47
All Rights Reserved - The Good Way Publishing - 2010
http://www.the-good-way.com
This expression:
    MY GRACE[a-zA-Z0-9/ ^13\-:.]{11,122}
Finds this:
MY GRACE IS SUFFICIENT FOR YOU 9/47
All Rights Reserved - The Good Way Publishing - 2010
http://www.the-good-way.com
of person he
So I thought this would be easy to resolve by adding "com" to the end
of my expression:
MY GRACE[a-zA-Z0-9/ ^13\-:.]{11,122}.com
thus limiting the find at that point. But that expression is not found
at all, which totally stumps me. I would appreciate any insight into
this.
I'm in Word 03 on Windows XP.
Thanks,
p.
 
T

Tony Jollans

The reason it didn't work is that the characters ., c, o, and m are all
matched within the existing pattern and, after Word has found up to 122 of
them, it does not then find .com. Word's wildcard pattern matching is not a
full RegEx, and it isn't looking ahead for .com.

--
Enjoy,
Tony

www.WordArticles.com

Wow, did that nail it! My continuing problem is that I don't know why
my expression ending in '.com' didn't work, or why 'MY GRACE *way.com'
was "non-greedy" in its findings, because many times I've found Word's
expressions to be greedy, capturing even multiple pages.

In any case, this makes the whole thing a lot simpler, and it's what I
will try first next time. Thanks much.

p.

Depending upon what else is in the document you could search for
MY GRACE *way.com

seehttp://www.gmayor.com/replace_using_wildcards.htm

or you could use a macro

Dim sFindText As String
Dim r As Range
Dim i As Long
sFindText = "MY GRACE IS SUFFICIENT"
Set r = ActiveDocument.Range
With r.Find
Do While .Execute(findText:=sFindText, Forward:=True) = True
r.End = r.Paragraphs(1).Range.End
r.MoveEnd wdWord, 21
If r.Characters.Last = Chr(32) Then
r.End = r.End - 1
End If
'Do what you want with the found text - r - here e.g.
MsgBox r
r.Collapse wdCollapseEnd
Loop
End With

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>




I'm almost there on a search expression, but the last step is
confounding me. Here's what I'm looking for:
MY GRACE IS SUFFICIENT FOR YOU 9/47
All Rights Reserved - The Good Way Publishing - 2010
http://www.the-good-way.com
This expression:
MY GRACE[a-zA-Z0-9/ ^13\-:.]{11,122}
Finds this:
MY GRACE IS SUFFICIENT FOR YOU 9/47
All Rights Reserved - The Good Way Publishing - 2010
http://www.the-good-way.com
of person he
So I thought this would be easy to resolve by adding "com" to the end
of my expression:
MY GRACE[a-zA-Z0-9/ ^13\-:.]{11,122}.com
thus limiting the find at that point. But that expression is not found
at all, which totally stumps me. I would appreciate any insight into
this.
I'm in Word 03 on Windows XP.
Thanks,
p.
 
P

Paul B.

Thanks Tony. In my mind, I told Word to find the 122 characters in the
bracketed class, and then go on to find the .com. But I guess Word
doesn't agree, and it gets the final say. I don't believe PERL
RegEx's, which I'm more used to, work that way.

p.

The reason it didn't work is that the characters ., c, o, and m are all
matched within the existing pattern and, after Word has found up to 122 of
them, it does not then find .com. Word's wildcard pattern matching is nota
full RegEx, and it isn't looking ahead for .com.

--
Enjoy,
Tony

 www.WordArticles.com


Wow, did that nail it! My continuing problem is that I don't know why
my expression ending in '.com' didn't work, or why 'MY GRACE *way.com'
was "non-greedy" in its findings, because many times I've found Word's
expressions to be greedy, capturing even multiple pages.

In any case, this makes the whole thing a lot simpler, and it's what I
will try first next time. Thanks much.

p.

Depending upon what else is in the document you could search for
MY GRACE *way.com

or you could use a macro
Dim sFindText As String
Dim r As Range
Dim i As Long
sFindText = "MY GRACE IS SUFFICIENT"
Set r = ActiveDocument.Range
With r.Find
Do While .Execute(findText:=sFindText, Forward:=True) = True
r.End = r.Paragraphs(1).Range.End
r.MoveEnd wdWord, 21
If r.Characters.Last = Chr(32) Then
r.End = r.End - 1
End If
'Do what you want with the found text - r - here e.g.
MsgBox r
r.Collapse wdCollapseEnd
Loop
End With
My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
news:2f684088-e856-49a8-986b-c9c207013579@x21g2000yqa.googlegroups.com....
I'm almost there on a search expression, but the last step is
confounding me. Here's what I'm looking for:
MY GRACE IS SUFFICIENT FOR YOU 9/47
All Rights Reserved - The Good Way Publishing - 2010
http://www.the-good-way.com
This expression:
MY GRACE[a-zA-Z0-9/ ^13\-:.]{11,122}
Finds this:
MY GRACE IS SUFFICIENT FOR YOU 9/47
All Rights Reserved - The Good Way Publishing - 2010
http://www.the-good-way.com
of person he
So I thought this would be easy to resolve by adding "com" to the end
of my expression:
MY GRACE[a-zA-Z0-9/ ^13\-:.]{11,122}.com
thus limiting the find at that point. But that expression is not found
at all, which totally stumps me. I would appreciate any insight into
this.
I'm in Word 03 on Windows XP.
Thanks,
p.
 
T

Tony Jollans

I don't know Perl, but I'm quite sure its Regexes are different. If you know
RegEx, you can use them in Word by instantiating a VBScript.RegExp object.

--
Enjoy,
Tony

www.WordArticles.com

Thanks Tony. In my mind, I told Word to find the 122 characters in the
bracketed class, and then go on to find the .com. But I guess Word
doesn't agree, and it gets the final say. I don't believe PERL
RegEx's, which I'm more used to, work that way.

p.

The reason it didn't work is that the characters ., c, o, and m are all
matched within the existing pattern and, after Word has found up to 122 of
them, it does not then find .com. Word's wildcard pattern matching is not
a
full RegEx, and it isn't looking ahead for .com.

--
Enjoy,
Tony

www.WordArticles.com


Wow, did that nail it! My continuing problem is that I don't know why
my expression ending in '.com' didn't work, or why 'MY GRACE *way.com'
was "non-greedy" in its findings, because many times I've found Word's
expressions to be greedy, capturing even multiple pages.

In any case, this makes the whole thing a lot simpler, and it's what I
will try first next time. Thanks much.

p.

Depending upon what else is in the document you could search for
MY GRACE *way.com

or you could use a macro
Dim sFindText As String
Dim r As Range
Dim i As Long
sFindText = "MY GRACE IS SUFFICIENT"
Set r = ActiveDocument.Range
With r.Find
Do While .Execute(findText:=sFindText, Forward:=True) = True
r.End = r.Paragraphs(1).Range.End
r.MoveEnd wdWord, 21
If r.Characters.Last = Chr(32) Then
r.End = r.End - 1
End If
'Do what you want with the found text - r - here e.g.
MsgBox r
r.Collapse wdCollapseEnd
Loop
End With
My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
news:2f684088-e856-49a8-986b-c9c207013579@x21g2000yqa.googlegroups.com...
I'm almost there on a search expression, but the last step is
confounding me. Here's what I'm looking for:
MY GRACE IS SUFFICIENT FOR YOU 9/47
All Rights Reserved - The Good Way Publishing - 2010
http://www.the-good-way.com
This expression:
MY GRACE[a-zA-Z0-9/ ^13\-:.]{11,122}
Finds this:
MY GRACE IS SUFFICIENT FOR YOU 9/47
All Rights Reserved - The Good Way Publishing - 2010
http://www.the-good-way.com
of person he
So I thought this would be easy to resolve by adding "com" to the end
of my expression:
MY GRACE[a-zA-Z0-9/ ^13\-:.]{11,122}.com
thus limiting the find at that point. But that expression is not found
at all, which totally stumps me. I would appreciate any insight into
this.
I'm in Word 03 on Windows XP.
Thanks,
p.
 

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