Regex Expression in VBA

"(http://)?([\w-]+\.)([\w-]+\.)?([\w-]+)([:/].*)?"

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


Tks
AXISHKAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
ozoConnect With a Mentor Commented:
.* matches any number of non-new line characters
0
 
ozoCommented:
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
0
 
Michael FowlerConnect With a Mentor Solutions ConsultantCommented:
The question mark tells the regex to match 0 or 1 of the preceding pattern

so

(http://)?  allows for the pattern "http://" to be present or missing
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
AXISHKAuthor Commented:
Tks

([:/].*)?  -

For ".*" ,  what does it actually mean ?
.            Matches any single character except a new line character
*            Matches preceding element zero or more times
0
 
Michael FowlerSolutions ConsultantCommented:
This matches any string which does not contain a new line. As it is zero or more times it will also match empty strings
0
 
AXISHKAuthor Commented:
Tks
0
All Courses

From novice to tech pro — start learning today.