Question Creating a MatchCollection that only includes “captured” () hits

Keith Howard

Active member
Joined
Jan 28, 2010
Messages
28
Programming Experience
5-10
Hello,

When I run the following line, the MatchCollection that is being created includes the underscore.

VB.NET:
Dim MatchCollection As System.Text.RegularExpressions.MatchCollection = System.Text.RegularExpressions.Regex.Matches(FSOFullPath, "_([A-Z]{5,5})")

I am trying to figure out how to capture into the MatchCollection only the expression in ( ), i.e. ([A-Z]{5,5}), with no underscore at the front. Is there a way to do this? Otherwise, I have will have to write another regular expression to remove the underscore from the front of each item in the MatchCollection, which brings up other problems. It would be much more effective to only add the captured expression to the MatchCollection in the first place. Searching without the underscore is not an option.

Many thanks in advance for your feedback.

Keith
 
Back
Top