Help in Regex

J

JM

Thanks for quick reply...
I will do replace for the remaining part of secondary URL to get the
hostname.

Regards
JM
 
K

Kevin Spencer

(http://).*\1[^/]*/

This does it without any additional work, and a bit more succinctly. It uses
a group and a backreference to grab the string up to the second "http" and
then indicates that any non-'/' character is a match. Finally, it matches
the next '/' character.

No character escapes are necessary, as the slashes are forward-slashes.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

What You Seek Is What You Get.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top