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

Regular Expressions

Avatar of undefined
Last Comment
Michael

8/22/2022 - Mon
Terry Woods

Try removing the g at the end, and see if that just gives the one match.
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.
louisfr

I think this part might be wrong:
\/S+

Open in new window

Maybe you meant
\S+ 

Open in new window

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
Michael

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.