Extracting second or third matches using Regular Expressions

L

lwert

I am from being an expert with Regular Expressions, so I am looking for some
help. I am looking to extract certain information from a line of text using
Regular Expressions, but have not found a way of doing it as I would prefer.

For example, I have found that I can parse the line:
Acme Consultants LLC Monterey, CA
using the VBScript RegEx.Execute and the regular expression:
^([\s\S]{1,30})([\s\S]*)(,)([\s\S]*)
and the objects of interest come out in the SubMatch structure. The problem
is that I need to identify which submatch apriori in some other way.

I would prefer to embed which submatch is of interest in the regular
expression itself. This is possible for the first part:
^[\s\S]{1,30}
as it will extract the first set of characters, but I am not sure how to
extract the second or third parts.

I have also looked at using RegEx.Replace, but find a similar challenge,
namely that I must indicate which part I want outside the regular expression.

Can anyone give me some ideas on how to incorporate a second or third match
in the regular expression itself?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top