PDA

View Full Version : Solved: Regular Expression in word



qazpl
11-20-2006, 05:49 AM
while experimenting with a search regular expression in word 03 vba I realizes that it stopped at 256 results. What am I doing wrong
This is the code I got from MVIDAS a while ago

Set RegEx = CreateObject("vbscript.regexp")
With RegEx
.Global = True
.MultiLine = True
.IgnoreCase = Not vMatchCase
.Pattern = vPattern
End With
ReDim mArr(0)
If RegEx.Test(vStr) Then
Set RegC = RegEx.Execute(vStr)
...........(I skipped the rest for now)

regC only get 256 matches even when there are many more
Am I doing something wrong
Thanks
qazpl

fumei
11-20-2006, 06:26 AM
When posting things like this, please tell us explicitly what happens. We can not see over your shoulder!

It stops...

Do you get an error message?
Does the code execution freeze?
Does it continue on, and the only way you know something is wrong is that you know there ARE more than 256?
Did you actually count them?

We can NOT see over your shoulder!

qazpl
11-20-2006, 06:37 AM
I Know that it only found 256 by creating a watch in vba
I know that there are more then 256 because I searched in word app Ctrl-F
I tried different words I tried just part of Doc and it will never find more then 256
No error message no freeze just array of results stops at 256
Thanks
qazpl

fumei
11-20-2006, 07:36 AM
OK, thanks. I am trying to do some test on this (I remember your post). I can not see why the array can not be redim'd gerater than 256. Hmmmmm. I am no RegEx expert.

mvidas????

qazpl
11-21-2006, 06:02 AM
Fumai I think it goes like this. For some reason the watch window doesn't show past 256 but in reality the array can be much larger.
I checked by writing

msgbox RegC.Count

and got the true number of results.

fumei
11-21-2006, 09:43 AM
Ah, I did not realize that you were ONLY talking about what you saw in the watch window........

So,
while experimenting with a search regular expression in word 03 vba I realizes that it stopped at 256 results. is not an accurate statement. It did not stop. You realized incorrectly. The Watch value stopped.

And
regC only get 256 matches is also not an accurate statement.

And
I tried different words I tried just part of Doc and it will never find more then 256
No error message no freeze just array of results stops at 256is also not accurate. It DID find more than 256. It did not "freeze". The Watch value froze...although I still don't know why.

I am not being critical here. That is why I asked some questions. We can't see what people see. We only know what people tell us. You told us the array stopped....which it did not.

However, I am glad it is working correctly. I was puzzled as I could not see any reason why the array would not continue correctly.

fumei
11-21-2006, 09:43 AM
Oh, and could you please mark this thread as Solved? Thanks.