Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Regex Expression in VBA

Posted on 2015-01-11
6
Medium Priority
?
111 Views
Last Modified: 2015-01-11
"(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
0
Comment
Question by:AXISHK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 84

Expert Comment

by:ozo
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
0
 
LVL 23

Assisted Solution

by:Michael Fowler
Michael Fowler earned 1000 total points
ID: 40543622
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
 

Author Comment

by:AXISHK
ID: 40543623
Tks

([:/].*)?  -

For ".*" ,  what does it actually mean ?
.            Matches any single character except a new line character
*            Matches preceding element zero or more times
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 23

Expert Comment

by:Michael Fowler
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
0
 
LVL 84

Accepted Solution

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

Author Closing Comment

by:AXISHK
ID: 40543633
Tks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

618 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