Skip to main content
Question

Formula to remove blank lines from text

  • July 27, 2023
  • 0 replies
  • 675 views

Hello, I have a field that is being generated by a pipeline and unfortunately due to the formatting of my jinja, creates blank lines:

Is there a way to format this via a formula text field so that it appears as follows:


or perhaps edit the jinja2 so that it doesn't create the spaces. I am open to all recommendations

Thank you
------------------------------
Shane Miller
------------------------------

This topic has been closed for replies.

Forum|alt.badge.img+20
  • Registered
  • July 28, 2023

Will the result always be in that exact format? ie, only 2 lines both starting with underscore?

_text

_moretext



------------------------------
Mike Tamoush
------------------------------

Forum|alt.badge.img+20
  • Registered
  • July 28, 2023

I'm sure editing the Jinja is probably best practice, so if someone knows Jinja, that is the way to go. I am not very good at Jinja, so try this in your formula field:

var text LinesRemoved = SearchAndReplace([testing jinja2 pipelines], "\n", "");

Trim(SearchandReplace($LinesRemoved, "_", "\n"))

//This is untested and I am not sure if Trim will remove the first blank line that will be put back in replacing the first underscore. If it doesn't work, let me know I have other ideas.



------------------------------
Mike Tamoush
------------------------------