RegEx: Pattern Matching going wrong: "\[.+\]\" 
Author Message
 RegEx: Pattern Matching going wrong: "\[.+\]\"

Hi,

When I use this patern
"\[.+\]\"

And this code:

For Each objMatch In objRegEx.Matches(txtTest.Text)

MsgBox(objMatch.Value)

Next

Value of the textbox (Case 1)

This is a test [to check for these boxes]

Then I get a messagebox with "[to check for these boxes]"

Value of the textobx (Case 2)

This is a test [to check] for [these boxes]

I expected to get 2 messageboxes "[to check]" and "[these boxex]"

Instead I got one  with "[to check] for [these boxes]"

How can I prevent this from happening and actually get 2 messageboxes
(2 Matches)

Thnx.



Mon, 28 Mar 2005 04:36:55 GMT  
 RegEx: Pattern Matching going wrong: "\[.+\]\"
Sorry I mistyped: "\[.+\]" but the question remains:
Quote:
> When I use this patern
> "\[.+\]"

> And this code:

> For Each objMatch In objRegEx.Matches(txtTest.Text)

> MsgBox(objMatch.Value)

> Next

> Value of the textbox (Case 1)

> This is a test [to check for these boxes]

> Then I get a messagebox with "[to check for these boxes]"

> Value of the textobx (Case 2)

> This is a test [to check] for [these boxes]

> I expected to get 2 messageboxes "[to check]" and "[these boxex]"

> Instead I got one  with "[to check] for [these boxes]"

> How can I prevent this from happening and actually get 2 messageboxes
> (2 Matches)

> Thnx.



Mon, 28 Mar 2005 04:43:41 GMT  
 RegEx: Pattern Matching going wrong: "\[.+\]\"
If found the solution
"\[[^\[\]]*\]"

So don't bother anymore :)



Quote:
> Hi,

> When I use this patern
> "\[.+\]\"

> And this code:

> For Each objMatch In objRegEx.Matches(txtTest.Text)

> MsgBox(objMatch.Value)

> Next

> Value of the textbox (Case 1)

> This is a test [to check for these boxes]

> Then I get a messagebox with "[to check for these boxes]"

> Value of the textobx (Case 2)

> This is a test [to check] for [these boxes]

> I expected to get 2 messageboxes "[to check]" and "[these boxex]"

> Instead I got one  with "[to check] for [these boxes]"

> How can I prevent this from happening and actually get 2 messageboxes
> (2 Matches)

> Thnx.



Mon, 28 Mar 2005 05:48:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Filename pattern matching using regex

2. RegEx object - Pattern Matching

3. The "Match" in "Matches"

4. Escape " (double quot) in regEXP pattern

5. "not match" in Regular Expressions (ASP)

6. Matching "algorithms"?

7. CType and "go to definition"

8. Pirate Pete goes "in character"

9. "WRONG VERSION OF RUN-TIME DLL"

10. *"*-.,._,.-*"* I"LL TRADE VISUAL C++ FOR VBASIC *"*-.,_,.-*"*

11. "Wrong runtime DLL"

12. Invalid "wrong NT Version" error

 

 
Powered by phpBB® Forum Software