Regex Expression in VBA

Posted on 2015-01-11
Last Modified: 2015-01-11

To verify my understanding, the submatch is
1. (http://)?
2. ([\w-]+\.)
3. ([\w-]+\.)?
4. ([\w-]+)
5. ([:/].*)?

The division of "?" is following the matching expression in each portion, correct ?

For the 5th submatch : ([:/].*)?, "?" mean zero or more for the expression within (). but what does ".*" mean ? Tks

Question by:AXISHK
  • 2
  • 2
  • 2
LVL 84

Expert Comment

ID: 40543621
The ? in (http://)? makes the match of http:// optional
The ? in ([\w-]+\.)? makes the match of [\w-]+\. optional
The ? in ([:/].*)? makes the match of [:/].* optional
LVL 23

Assisted Solution

Michael74 earned 250 total points
ID: 40543622
The question mark tells the regex to match 0 or 1 of the preceding pattern


(http://)?  allows for the pattern "http://" to be present or missing

Author Comment

ID: 40543623

([:/].*)?  -

For ".*" ,  what does it actually mean ?
.            Matches any single character except a new line character
*            Matches preceding element zero or more times
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

LVL 23

Expert Comment

ID: 40543626
This matches any string which does not contain a new line. As it is zero or more times it will also match empty strings
LVL 84

Accepted Solution

ozo earned 250 total points
ID: 40543627
.* matches any number of non-new line characters

Author Closing Comment

ID: 40543633

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question