-1

Example :

  1. I have stored below html tag as one field in data extension. I need to retrieve the href url from this. How to retrieve this ? and also How to retrieve "Visit google.com!" from html stored in data extension
  2. How to send the HTML code in the data extension field as an email attachment? How to send the below code as email attachment in email ?

HTML :

<h1> The a element </h1>
<a href="https://www.google.com">Visit google.com!<a>
2
  • 2
    What approach have you tried? In what context do you want to retrieve this information? SQL, CloudPage or at send time in a message? Are you able to retrieve the full row? Share some code you tried to use Commented Apr 17, 2023 at 10:56
  • I need to extract the url alone from html which stored in data extension.Then i use url as attachment in email.
    – Test SFMC
    Commented Apr 18, 2023 at 7:15

1 Answer 1

0

Using AMPscript RegExMatch function would help to get the URL.

Update to get both URL and link text. Try this:

%%[
  set @html = AttributeValue('Your column name');

  set @url_Pattern = '(?<=href=").*(?=")'
  set @linkText_Pattern = '(?<=>).*(?=<a>)'

  set @url = RegExMatch(@html, @url_Pattern, 0)
  set @linkText = RegExMatch(@html, @linkText_Pattern, 0)
]%%

URL: %%=v(@url)=%%<br>
Link Text: %%=v(@linkText)=%%

Reference: RegExMatch function

4

Not the answer you're looking for? Browse other questions tagged .