Regex Extraction from url

Hi All,

I want to extract only the 00676000009tTAyAAM from below url .How can I use regex for that

https://sandbox--uat2.sandbox.lightning.force.com/lightning/r/Opportunity/00676000009tTAyAAM/view

Hi @marina.dutta

Check the below regular expression,

- Assign -> Input = "https://sandbox--uat2.sandbox.lightning.force.com/lightning/r/Opportunity/00676000009tTAyAAM/view"
- Assign -> Output = System.Text.RegularExpressions.Regex.Match(Input.toString,"(?<=Opportunity/)[\d\w]+").Value

Check the below workflow for better understanding,

Hope it helps!!

1 Like


\d+[A-Za-z]+
Try this

1 Like

@marina.dutta

Is it always between oppurtunity and view

(?<=Opportunity/).*(?=/view)

Cheers

1 Like

@Anil_G

yes its always between opportunity and view

1 Like

@marina.dutta

Try the above

Usage Requiredval = system.Text.RegularExpressions.Regex.Match(str,"(?<=Opportunity/).*(?=/view)").Value

Cheers

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.