Link to home
Start Free TrialLog in
Avatar of Michael
Michael

asked on

Help with Regex

HI im trying to extract this url from an email using regex. My Regex string is 


/href=\"(https:\/\/www.linkedin.com\/e\/v2\/S+)/g


The string I'm looking for is:

href="https://www.linkedin.com/e/v2?e=4mwol-kx0cskhe-b2&lipi=urn%3Ali%3Apage%3Aemail_email_jobs_new_applicant_01%3BQXTCX4qcT7OfUsLaH3cuLA%3D%3D&t=plh&midToken=AQG80kTcNtwiXA&ek=email_jobs_new_applicant_01&li=0&m=email_jobs_new_applicant&ts=job_posting_download_resume&urlhash=dt4R&url=https%3A%2F%2Fwww%2Elinkedin%2Ecom%2Ftalent%2Fapi%2FtalentResumes%3FapplicationId%3D8549340446%26tokenId%3D1524127108%26checkSum%3DAQGg2sABm2nopxlP8EhnWBw3EtcLXz1U"


My issue is the string href="https://www.linkedin.com/e/v2 is used a few times in the email so the regex is flawed. It matches up to three times


I have some options to consider, Can i have regex stop after it finds 1 match? Or can i add that it must contain the string download_resume? 


Language is Javascript


thanks in advance

Avatar of Terry Woods
Terry Woods
Flag of New Zealand image

Try removing the g at the end, and see if that just gives the one match.
Avatar of Dr. Klahn
Dr. Klahn

The separating periods must be escaped.  As it stands this part of the regex allows incorrect matches.  That section should be:

https:\/\/www\.linkedin\.com

Make that change and see what happens.
I think this part might be wrong:
\/S+

Open in new window

Maybe you meant
\S+ 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Michael
Michael

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial