Forum Discussion

GabeFigueroa1's avatar
GabeFigueroa1
Qrew Member
2 years ago

insert newline into API downloaded text

A Pipeline API successfully retrieves text into the QuickBase Rich text field.  The sometimes-lengthy text does not have any CRLF so the text is all run together. The User will be editing the text ...
  • DougHenning1's avatar
    DougHenning1
    2 years ago

    There's a regex filter, so you can use that instead of the "Find All Matches to a RegEx" step.  This code should go in the field to store the text with the line breaks added:

    {% set ns = namespace(data=c.claim) -%}
    {% set myList = ns.data | regex('[^0-9]\d{1,4}\.\s', true) -%}
    {% for x in myList -%}
      {% set ns.data = ns.data.replace(x|string,  (x|string)[0] ~ '<br>' ~ (x|string)[1:]) -%}
    {% endfor -%}
    {{ ns.data }} 

    Line 1: need a namespace to modify a variable inside a loop

    Line 2: use regex to get a list of the numbers to break on, including the preceding character which is needed in the replace.

    Line 4: Add a line break before the number, and add the preceding character back before the line break.

    Hope that helps!



    ------------------------------
    Doug Henning
    ------------------------------