regular expression to extract elements from url

  • Thread starter Thread starter jarod1701
  • Start date Start date
J

jarod1701

Hi,

I'm currently trying to create a regular expression that can extract
certain elements from a url.

The url will be of the following form:
http://user:[email protected]

I want a regex that matches the "user" part of that url.

My first approach was ([:][/][/]([a-z]*)[:]) but that only return
"://user:".

I would have to use .NET's substring method to extract the "user" but I
don't want to do that.
I've been searching through the web for quite a while now
Isn't there a way to get the substring from "://user:" using something
like a subpattern ?

Is it possible after all ?

Thanks in advance
 
What do you exactly want to extract? You can extract the elements to
some group.

Try the following.

(http://)(?<User>.*):(?<Password>.*)@.*

it will extract the user into the <User> group, and pass into <Password>
group.

HTH.

Jianwei
 
Back
Top