My code could be given any of the 3 possible URLS below, and I'd like to extract the user name 'mrsmith' which could be any kind of user name depending on the URL being passed, while the 'somewebsite', '/artist/' and '/portfolio/' remain constant:
http://www.somewebsite.com/artist/mrsmith
http://mrsmith.somewebsite.com/
http://mrsmith.somewebsite.com/portfolio/variablenames
Is there an elegant way to do this using regex?
mrsmith
, or the rest of the URL? – slugster