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
Jezebel - 16 Mar 2007 09:52 GMT
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
> hi all
>
[quoted text clipped - 13 lines]
>
> many thanks
Helmut Weber - 16 Mar 2007 13:52 GMT
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 ' !!

Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Klaus Linke - 16 Mar 2007 20:47 GMT
In case you use the Like operator, try
myParagraph.Range.Text Like ("Chapter [0-9]" & vbCr)
Regards,
Klaus
> hi all
>
[quoted text clipped - 13 lines]
>
> many thanks