Delete specific line with regex replace command

Hi,

The box section contains only letters. Example xxxxxx yy zzzzz. The values here can change constantly. xx yyyyyy zz maybe.

My question is, I just want to delete the row with the negative amount completely.

For example, I want to delete this data 01.12.2023 2477 xxxxxx yy zzzzz 240912.03 241076.36 -164.33

Hi @Mesut_Can

Try this

System.Text.RegularExpressions.Regex.Replace(Input,"\d+.*\-\d+.*","")

Hope it helps
Regards

Hi @Mesut_Can

Input:

=> Use below syntax in Assign activity:

Output= System.Text.RegularExpressions.Regex.Replace(Input,"\d+.*\-\d+.*","")

=> Use Write Text File to write the output

Output:

Refer below workflow for better understanding

Regards

@Mesut_Can

Welcome to the community

Do you need to check only the last column for negative values …if so you can use this

This checks strictly in the last column always…and also replaces the bew line as well

.+(?<=-\d+(\.\d+)?$)\r?\n

System.Text.RegularExpressions.Regex.Replace(str,".+(?<=-\d+(\.\d+)?$)\r?\n","")

Cheers

1 Like

Thank you very very much.

2 Likes

You’re Welcome @Mesut_Can

Happy Automation

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.