Select a HostName with Regex in C# ?
-
Hi, There are some addresses as follows :
http://rs320tl.rapidshare.com/files/119371167/sth.rar
I'm gonna select
rs320tl.rapidshare.com
withRegex
, but I'm not familiar with Regular Expressions. Would you please guide me ? Thanks. PS.rs320tl
in the address is variable. -
Hi, There are some addresses as follows :
http://rs320tl.rapidshare.com/files/119371167/sth.rar
I'm gonna select
rs320tl.rapidshare.com
withRegex
, but I'm not familiar with Regular Expressions. Would you please guide me ? Thanks. PS.rs320tl
in the address is variable.^(ftp|http|file)://([^/]+)(/.*)?(/.*)
so
http :// www.codeproject.com /forum /xxx.html
1 2 3 4so the reg expression would spit out $1 = http $2 = www.codeproject.com $3 = /forum $4 = /xxx.html hope this helps.
-
Hi, There are some addresses as follows :
http://rs320tl.rapidshare.com/files/119371167/sth.rar
I'm gonna select
rs320tl.rapidshare.com
withRegex
, but I'm not familiar with Regular Expressions. Would you please guide me ? Thanks. PS.rs320tl
in the address is variable.Try this instead of a Regex:
MessageBox.Show((new Uri("http://rs320tl.rapidshare.com/files/119371167/sth.rar")).Host);
-
Try this instead of a Regex:
MessageBox.Show((new Uri("http://rs320tl.rapidshare.com/files/119371167/sth.rar")).Host);
I didn't know that a Uri broke it down for you - thanks for that!:thumbsup:
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
-
Try this instead of a Regex:
MessageBox.Show((new Uri("http://rs320tl.rapidshare.com/files/119371167/sth.rar")).Host);
Under which namespace .host is come
-
Under which namespace .host is come
I think you mean Uri. It's in the System namespace.
-
Try this instead of a Regex:
MessageBox.Show((new Uri("http://rs320tl.rapidshare.com/files/119371167/sth.rar")).Host);
Thanks, but it throws an Exceptions on
MessageBox.Show((new Uri("rs320tl.rapidshare.com")).Host);
-
^(ftp|http|file)://([^/]+)(/.*)?(/.*)
so
http :// www.codeproject.com /forum /xxx.html
1 2 3 4so the reg expression would spit out $1 = http $2 = www.codeproject.com $3 = /forum $4 = /xxx.html hope this helps.
Thanks, How can I store $2 in a string?
-
Thanks, but it throws an Exceptions on
MessageBox.Show((new Uri("rs320tl.rapidshare.com")).Host);
-
Thanks, How can I store $2 in a string?
string str = (new Regex("the pattern")).Match("the string").Groups[2].Value;
-
^(ftp|http|file)://([^/]+)(/.*)?(/.*)
so
http :// www.codeproject.com /forum /xxx.html
1 2 3 4so the reg expression would spit out $1 = http $2 = www.codeproject.com $3 = /forum $4 = /xxx.html hope this helps.
It doesn't work with
www.codeproject.com