I have a bunch of domain names coming in like this:
http://subdomain.example.com (example.com is always example.com, but the subdomain varies).
I need “subdomain”.
Could some kind person who had the patience to learn regex help me out?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Then $3 (or \3) will contain “subdomain” if one was supplied.
If you want to have the subdomain in the first group, and your
regex engine supports non-capturing groups (shy groups), use
this as suggested by palindrom: