Answers.Body: <p>You could write a module that adds a twig extension to return the value of src from the string. That way you get to utilise PHP as per <a href="https://stackoverflow.com/questions/17017684/how-to-get-url-from-the-iframe-using-php">https://stackoverflow.com/questions/17017684/how-to-get-url-from-the-iframe-using-php</a> to get the value.</p>
  
  <p><a href="https://pluginfactory.io/" rel="nofollow noreferrer">https://pluginfactory.io/</a> is a good starting point for adding a module to Craft.</p>
  
  <p>alternative very dirty approach: If the iframe markup is always going to be the same, you could do <code>|replace()</code>, replacing everything before the <code>src="</code> and everthing after the <code>" width</code> with empty strings. Then replace <code>" width</code> with an empty string.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-13T13:35:06.817Z
Answers.Text: Thank you @mijewe! Never built a plugin, but yes, it will always be generated iframe from a Pardot form every time. I think I will try and get the |replace to work.
Answers.UserDisplayName: mateostabio
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-13T10:10:41.557Z
Answers.LastActivityDate: 2019-03-13T10:10:41.557Z
Answers.UserDisplayName: mijewe
Body: <p>I have have a text field for copy-pasting an iFrame code.</p>
  
  <pre><code>&lt;iframe src="https://webpagelink.com/l/3556456/2019-03-06/34576" width="100%" 
  height="500" type="text/html" frameborder="0" allowTransparency="true" 
  style="border: 0"&gt;&lt;/iframe&gt;
  </code></pre>
  
  <p>What I need help with is striping out the URL within the <code>src=""</code> value from the iframe. Is this possible using Twig?</p>
  
  <p>Thank you for your help!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-12T23:16:59.997Z
Comments.Text: Do you want to _remove_ the `src` attribute from the iframe HTML code, or do you want to strip everything _but_ the `src` attribute (e.g. end up with a variable containing the URL in the original `src` attribute)?
Comments.UserDisplayName: Mats Mikkel Rummelhoff
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-13T00:59:25.530Z
Comments.Text: Yeah like Mats I'm curious what you're trying to achieve here...
Comments.UserDisplayName: Jalen Davenport
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-14T15:08:51.230Z
Comments.Text: @MatsMikkelRummelhoff - My client copy/pastes iframe codes in, and now we realized that I need to inject a variable with entry.title into the iframe. So yes, I just need to get the url only.
Comments.UserDisplayName: mateostabio
Tags: <templating><twigextension><plaintext>
Title: How to strip out src="" value with twig from iframe code
ThreadText: # How to strip out src="" value with twig from iframe code
  
  (Asked by: username_0 on 2019-03-12)
  
  I have have a text field for copy-pasting an iFrame code.
  
  ```
  <iframe src="https://webpagelink.com/l/3556456/2019-03-06/34576" width="100%" 
  height="500" type="text/html" frameborder="0" allowTransparency="true" 
  style="border: 0"></iframe>
  
  ```
  
  What I need help with is striping out the URL within the `src=""` value from the iframe. Is this possible using Twig?
  
  Thank you for your help!
  
  **Tags:** templating, twigextension, plaintext
  
  > **Comments:**
  > **username_1**: Do you want to _remove_ the `src` attribute from the iframe HTML code, or do you want to strip everything _but_ the `src` attribute (e.g. end up with a variable containing the URL in the original `src` attribute)?  
  > **username_2**: Yeah like username_1 I'm curious what you're trying to achieve here...  
  > **username_0**: @username_1 - My client copy/pastes iframe codes in, and now we realized that I need to inject a variable with entry.title into the iframe. So yes, I just need to get the url only.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2019-03-13. Score: 2 | Accepted answer
  
  You could write a module that adds a twig extension to return the value of src from the string. That way you get to utilise PHP as per <https://stackoverflow.com/questions/17017684/how-to-get-url-from-the-iframe-using-php> to get the value.
  
  <https://pluginfactory.io/> is a good starting point for adding a module to Craft.
  
  alternative very dirty approach: If the iframe markup is always going to be the same, you could do `|replace()`, replacing everything before the `src="` and everthing after the `" width` with empty strings. Then replace `" width` with an empty string.
  
  > **Comments:**
  > **username_0**: Thank you @username_3! Never built a plugin, but yes, it will always be generated iframe from a Pardot form every time. I think I will try and get the |replace to work.  
  
  ---
  
  