-2

so i've been searching for solutions as to how to extract a particular url from an email body, but many seem to be extensive or a bit confusing. This is the email href:

<a href="http://matrix.ms.com/" target="_blank" data-saferedirecturl="https://www.google.com/url?q=http://matrix.ms.com/&amp;source=gmail&amp;ust=1591284067791000&amp;usg=AFQjCNGSmpctZFZau9kOCv8xa9Abu8a-uQ">Matrix.ms.com</a>

I only want to extract the http://matrix.ms.com/ portion (the link between the quotation marks). This is sort of how I got the ball rolling but im a bit lost from here:

(?<=href\=").*(?="\>)

Any help is appreciated!

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
slysyn24
  • 17
  • 3
  • Does this answer help?[regular-expression-for-finding-href-value-of-a-a-link](https://stackoverflow.com/questions/15926142/regular-expression-for-finding-href-value-of-a-a-link) –  Jun 03 '20 at 15:55

1 Answers1

-2

You can use this regex to catch the link:

href.+?[\'|\"]+?([^\'|\"]+)?[\'|\"]

Working example: https://regex101.com/r/GtPNW0/1

Nabeel Khan
  • 3,715
  • 2
  • 24
  • 37