I am looking for a way within PHP to pull the second link http://secure.hello.com out of the following string via regex.
http://hello.com/http://secure.hello.com
The string may or may not contain https in either of the spots.
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.
Try this regular expression:
It searches for the first
://then searches for a slash followed by some word characters, then://, then anything apart from spaces. The text you want is in the first capturing group.In a PHP string literal it can be written as:
See it working online: ideone
If you want to restrict to http or https, change the
\w+tohttps?.