regexp question

V

vbaNOOB

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
 
J

Jezebel

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
 
H

Helmut Weber

K

Klaus Linke

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

Regards,
Klaus
 

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