Answers.Body: <p>Completely untested, but you should be able to do use something like the <a href="https://github.com/victor-in/Craft-TwigPCRE" rel="nofollow">Craft-TwigPCRE</a> plugin and some variation of this code:</p>
  
  <pre><code>{% set text = "&lt;p&gt;Some text&lt;/p&gt; tags as well as stuff like &lt;strong&gt;.|preg_replace('/\&lt;p\&gt;/', '') %}
  
  {% set text = text|preg_replace('/\&lt;\/p\&gt;/', '\\n') %}
  </code></pre>
  
  <p><code>\n</code> is the Line Feed control character for Unix/OSX.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-11T12:09:38.423Z
Answers.Text: Many thanks Brad, I will take a look later this afternoon and let you know how I get on.
Answers.UserDisplayName: Pathfinder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-11T13:41:59.473Z
Answers.Text: Okay, spent some time on this one and ran into several issues.
  
  The feed I tested it on is here: https://flourish-uk.com/indeed2.xml
  
  The issues are that without |raw the text comes in with the symbol codes instead, so &lt; etc instead of the actual <p> tags.
  
  In addition, while the preg_replace works, it struggles when |raw is enabled - nothing appears!
  
  Using preg_replace as a test, I can get it to display the text with the extra symbols - replace them - but \\n appears as just that \\n and not a new line.
Answers.UserDisplayName: Pathfinder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-11T13:52:55.150Z
Answers.Text: Updated and simplified the XML for now, to show the issues.
Answers.UserDisplayName: Pathfinder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-10T18:32:00.973Z
Answers.LastActivityDate: 2015-08-10T18:32:00.973Z
Answers.UserDisplayName: Brad Bell
Body: <p>I am exporting some fields to an XML feed. There is a rich text field with typically 4 paragraphs in it.</p>
  
  <p>The default export kicks out:</p>
  
  <pre><code>&lt;p&gt;Some text&lt;/p&gt; tags as well as stuff like &lt;strong&gt;.
  </code></pre>
  
  <p>This is easy to remove with |striptags.</p>
  
  <p>However, this results in text that doesn't have proper spacing and removes any intended carriage returns.</p>
  
  <p>I can fix the spacing with a</p>
  
  <pre><code>|replace(".", ". ")
  </code></pre>
  
  <p>But I'd rather have the the Paragraphs to still have carriage returns as intended. I know I can add in the right UTF-8 symbol, but I don't want this in the data, I just want the spacing and carriage returns as if it were a plain text field and not to have the UTF-8 symbols in the feed itself.</p>
  
  <p><a href="http://www.fileformat.info/info/unicode/char/000D/index.htm" rel="nofollow">http://www.fileformat.info/info/unicode/char/000D/index.htm</a></p>
  
  <p>Any help, much appreciated.</p>
  
Tags: <replace>
Title: Can I convert rich text field to have plain text output - with carriage returns?
ThreadText: # Can I convert rich text field to have plain text output - with carriage returns?
  
  (Asked by: username_0 on 2015-08-10)
  
  I am exporting some fields to an XML feed. There is a rich text field with typically 4 paragraphs in it.
  
  The default export kicks out:
  
  ```
  <p>Some text</p> tags as well as stuff like <strong>.
  
  ```
  
  This is easy to remove with |striptags.
  
  However, this results in text that doesn't have proper spacing and removes any intended carriage returns.
  
  I can fix the spacing with a
  
  ```
  |replace(".", ". ")
  
  ```
  
  But I'd rather have the the Paragraphs to still have carriage returns as intended. I know I can add in the right UTF-8 symbol, but I don't want this in the data, I just want the spacing and carriage returns as if it were a plain text field and not to have the UTF-8 symbols in the feed itself.
  
  <http://www.fileformat.info/info/unicode/char/000D/index.htm>
  
  Any help, much appreciated.
  
  **Tags:** replace
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-08-10. Score: 1
  
  Completely untested, but you should be able to do use something like the [Craft-TwigPCRE](https://github.com/victor-in/Craft-TwigPCRE) plugin and some variation of this code:
  
  ```
  {% set text = "<p>Some text</p> tags as well as stuff like <strong>.|preg_replace('/\<p\>/', '') %}
  
  {% set text = text|preg_replace('/\<\/p\>/', '\\n') %}
  
  ```
  
  `\n` is the Line Feed control character for Unix/OSX.
  
  > **Comments:**
  > **username_0**: Many thanks username_1, I will take a look later this afternoon and let you know how I get on.  
  > **username_0**: Okay, spent some time on this one and ran into several issues.  The feed I tested it on is here: https://flourish-uk.com/indeed2.xml  The issues are that without |raw the text comes in with the symbol codes instead, so &lt; etc instead of the actual <p> tags.  In addition, while the preg_replace works, it struggles when |raw is enabled - nothing appears!  Using preg_replace as a test, I can get it to display the text with the extra symbols - replace them - but \\n appears as just that \\n and not a new line.  
  > **username_0**: Updated and simplified the XML for now, to show the issues.  
  
  ---
  
  