Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2007

Tip: Looking for answers? Try searching our database.

regexp question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
vbaNOOB - 16 Mar 2007 09:20 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.