hi all

it's me again
In my vba program, I've created an new regexp called "reg"
the program will match the first paragraph in the active doc using the
reg.test

the program is how should I write the pattern to match "Chapter X"
I try the pattern "Chapter[ ][0-9]"
but it will also match a line like "Chapter 3342545435342543543543"
how should I tell regexp that it's end line??

I've try another like pattern "Chapter[ ][0-9]\n" , pattern "Chapter[
][0-9]^13"
but they cant match anything

many thanks

Re: regexp question by Jezebel

Jezebel
Fri Mar 16 03:52:05 CDT 2007

You seem to have lost the plot somewhere.

1. [] matches the contents of the brackets -- ie, nothing. It does not match
a single space or any number of spaces.

2. [0-9] matches any ONE digit. It does not match "3342545435342543543543".

I guess the bug in your code is elsewhere



"vbaNOOB" <vbaNOOB@discussions.microsoft.com> wrote in message
news:0E55CA54-A39B-4E9C-AF33-B59569536F0D@microsoft.com...
> hi all
>
> it's me again
> In my vba program, I've created an new regexp called "reg"
> the program will match the first paragraph in the active doc using the
> reg.test
>
> the program is how should I write the pattern to match "Chapter X"
> I try the pattern "Chapter[ ][0-9]"
> but it will also match a line like "Chapter 3342545435342543543543"
> how should I tell regexp that it's end line??
>
> I've try another like pattern "Chapter[ ][0-9]\n" , pattern "Chapter[
> ][0-9]^13"
> but they cant match anything
>
> many thanks



Re: regexp question by Helmut

Helmut
Fri Mar 16 07:52:16 CDT 2007

Hi,

try:

Chapter [0-9]{1,}[^l^13]

\n reminds me of Unix as new line.

It doesn't work in Word.

\ must be followed by a quotable (or control) character,
so to speak, like \ { } [ ] @
though, if it is followed by a non quotable character,
it doesn't rise an error.

See:
http://word.mvps.org/faqs/general/UsingWildcards.htm
http://www.gmayor.com/replace_using_wildcards.htm ' !!

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"





Re: regexp question by Klaus

Klaus
Fri Mar 16 14:47:29 CDT 2007

In case you use the Like operator, try
myParagraph.Range.Text Like ("Chapter [0-9]" & vbCr)

Regards,
Klaus


"vbaNOOB" wrote:
> hi all
>
> it's me again
> In my vba program, I've created an new regexp called "reg"
> the program will match the first paragraph in the active doc using the
> reg.test
>
> the program is how should I write the pattern to match "Chapter X"
> I try the pattern "Chapter[ ][0-9]"
> but it will also match a line like "Chapter 3342545435342543543543"
> how should I tell regexp that it's end line??
>
> I've try another like pattern "Chapter[ ][0-9]\n" , pattern "Chapter[
> ][0-9]^13"
> but they cant match anything
>
> many thanks