RegExp object, matches collection, and sub-patterns 
Author Message
 RegExp object, matches collection, and sub-patterns

The language reference for VBScript 5 says, under the Pattern property of
the RegExp object:

(pattern)  Matches pattern and remembers the match. The matched substring
can be retrieved from the resulting Matches collection, using Item
[0]...[n]. To match parentheses characters ( ), use "\(" or "\)".

Except, no where else is this mentioned and I can't get it to work.  The
matches collection seems to have only one match that is for the whole
pattern, not my sub-pattern.  I know the subpattern is matching fine because
a replace (that does use sub-patterns) works fine.

Does anyone know how to retrieve the values of sub-pattern matches in
VBScript regular expressions?

Thanks!



Sun, 01 Sep 2002 03:00:00 GMT  
 RegExp object, matches collection, and sub-patterns
My recollection is that this a known problem that is fixed in the version 5.5 beta.  The VBScript
RegExp object has been significantly enhanced.

--
Michael Harris
MVP Scripting

The language reference for VBScript 5 says, under the Pattern property of
the RegExp object:

(pattern)  Matches pattern and remembers the match. The matched substring
can be retrieved from the resulting Matches collection, using Item
[0]...[n]. To match parentheses characters ( ), use "\(" or "\)".

Except, no where else is this mentioned and I can't get it to work.  The
matches collection seems to have only one match that is for the whole
pattern, not my sub-pattern.  I know the subpattern is matching fine because
a replace (that does use sub-patterns) works fine.

Does anyone know how to retrieve the values of sub-pattern matches in
VBScript regular expressions?

Thanks!



Sun, 01 Sep 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. RegExp Pattern for Matching a URL?

2. RegExp Pattern for Matching a URL?

3. RegExp pattern matching

4. RegExp pattern-matching problem

5. RegExp - Match ANY repeating pattern

6. Help Needed with Pattern Matching & regexp

7. RegExp pattern-matching problem

8. RegExp Pattern for Matching a URL?

9. RegExp Pattern Matching Bug

10. RegExp pattern-matching problem

11. Pattern matching with RegExp

12. RegExp Object and match.value be entire line

 

 
Powered by phpBB® Forum Software