[SOLVED] Remove line breaks

mbeckmann
mbeckmann New Altair Community Member
edited November 5 in Community Q&A
Hi folks,

I'm looking for a way to remove all the line breaks from a text.

I've tried \r\n, regex, without success.


Could you please help me?

Thanks in advance,
Tagged:

Answers

  • MariusHelf
    MariusHelf New Altair Community Member
    Hi,

    try the Replace operator to replace \n with nothing, as in the process below (the first two operators are just to create an example set which contains values with linebreaks).
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.2.003">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="5.2.003" expanded="true" name="Process">
        <process expanded="true" height="116" width="614">
          <operator activated="true" class="text:create_document" compatibility="5.2.001" expanded="true" height="60" name="Create Document" width="90" x="112" y="30">
            <parameter key="text" value="first&#10;second&#10;line"/>
          </operator>
          <operator activated="true" class="text:documents_to_data" compatibility="5.2.001" expanded="true" height="76" name="Documents to Data" width="90" x="313" y="30">
            <parameter key="text_attribute" value="text"/>
          </operator>
          <operator activated="true" class="replace" compatibility="5.2.003" expanded="true" height="76" name="Replace" width="90" x="514" y="30">
            <parameter key="replace_what" value="(\n)"/>
          </operator>
          <connect from_op="Create Document" from_port="output" to_op="Documents to Data" to_port="documents 1"/>
          <connect from_op="Documents to Data" from_port="example set" to_op="Replace" to_port="example set input"/>
          <connect from_op="Replace" from_port="example set output" to_port="result 1"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
          <portSpacing port="sink_result 2" spacing="0"/>
        </process>
      </operator>
    </process>
    Best,
    Marius
  • mbeckmann
    mbeckmann New Altair Community Member
    Thanks, this works fine!