delete last character form a string

hi collegues,

I need to delete “,” on each line, only in the situation where this is the last string in the cell.
ssssss

I tried string manipulation node with the following formula, but it deletes all my “,” characters, not just from the end of the line: regexReplace($COMENT$, "(.),", “$1”)*

Can help me with an ideea, please…
thx,
Mada

Hi @madac,

Try this in String Manipulation:

regexReplace($COMENT$, "^(.*?),*\\s*$", "$1")

^ start of line
(.*?) any number of any characters non-greedily, so allows it to find the final optional comma etc in the remainder of the regex, captured as capture group
,* any number of commas together
\\s* any amount of white space after the comma
$ end of line

If you don’t want to remove multiple successive commas from the end , but only the final one (if such a situation can occur) then remove the * from the ,* and if you don’t want to remove the final comma if it is followed by white space, remove the \\s* part

e.g. it could be simply:
regexReplace($COMENT$, "^(.*?),$", "$1")

2 Likes

thank you!
i try this regexReplace($COMENT$, "^(.*?),*\\s*$", "$1") and it works!

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