cancel
Showing results for 
Search instead for 
Did you mean: 

removing empty rows from a string

MarcoMatuttis
Level 3

I used blueprism to get html code of a website. I used standard string operations like replace and regex etc. to modify the html to get a result like this:

35899.png
I would like to "trim" every single line of the string and remove the lines that have no characters but I'm not able to do it.

I thought about a regex replace but somehow I can not get the regular expression right. I use the AVO.regex and tried to use some stuff i found on google which seems to work on regex101:
35900.pngheres the way i built it:
35901.png35902.png

Anyone got an idea how I could manipulate the string?

1 BEST ANSWER

Helpful Answers

MarcoMatuttis
Level 3

I found a solution now:

I make a regex serach for all lines that have content and put them in a collection. Then I juse join lines with that collection and get a string without empty lines. After that I have to rename the collection field because the  join lines action expects a collection with that field name.
35898.png

View answer in original post

3 REPLIES 3

MarcoMatuttis
Level 3

I managed to trim every line with 

[ ]{2,}

as input for the regex pattern but still can't get rid of the empty lines.

Hi Marco Matuttis,

1) If you want to just replace new line and append all text  you can use Replace([Data1], NewlIne(),"")

Data1=
 First Line 09/30/2023

         Name:  <Name>
               Adress: <Address>
         
             Telephone: 000378932
 
 
 
            Terlrphone" 238930303
 
 
 
 
 
          ServiceNumber: q23425093509285095
2) If you want to just remove the empty lines and keep the text as is. you can try  Below steps:
Step1: Replace([Data1], " ", "")
35893.png
Step2: Split Lines
35894.png
Step3: Remove empty rows
35895.pngStep4: check it is first row/Line >
if it is first row just add the split value text to final text
35896.png
Step5:  your calculation stage looks like this if it is other than 2nd row
[FinalText]&NewLine()&[Split Values.Value]
35897.png

-----------------------
If I answered your query. Please mark it as the Best Answer

Harish Mogulluri

MarcoMatuttis
Level 3

I found a solution now:

I make a regex serach for all lines that have content and put them in a collection. Then I juse join lines with that collection and get a string without empty lines. After that I have to rename the collection field because the  join lines action expects a collection with that field name.
35898.png