Regexreplace - depending on order of actions, it works or it doesn't

Hello,

Here I attach a sample EasyMorph project, using the new regexreplace function. In action 3 I’m deleting 1 or more line breaks at the end of each cell, and in action 4 I’m replacing 2 or more line breaks (in any part of the cell) with 1 line break. In the project, you can see how Row 3 of the table changes when you execute action 3 (it deletes the line break at the end).

However, if I swap actions 3 and 4, the action where I’m deleting 1 or more line breaks at the end of each cell (which is now action 4) does not do anything in Row 3 - the line break at the end is not deleted, when it should be.

Why is this ocurring?

I attach the EasyMorph project + input data.

Thanks,

Roberto

Reemplazarcaracteres.morph (4.8 KB) Datos originales.xlsx (8.2 KB)

Hello @roberto,
The reason is that “linebreak()” produces a string containing “\r\n” for non-Unix platforms, or a string containing “\n” for Unix platforms. So when you changed action order you replace \n\n with \r\n. If you update new action 4 to “regexreplace([Datos modificados],’’,’\r\n+$’)” the issue will be fixed

1 Like