Remove last character from string

0
Hi all,  if I have a string, for example  This is my string, Is there anything I can do (needs to be in a microflow) maybe using a java action where I can remove the comma at the end?  So the output would be just This is my string
asked
3 answers
4

This can be solved by determining the length of the string first with the ‘length’ function. Use the integer you get out of this function as inputparameter when calling the function ‘substring’, like:

substring($yourstring, 0 , (length – 1))

see also:

https://docs.mendix.com/refguide/string-function-calls

answered
1

Hi!

You can use a "Change Variable” action:

if endsWith($Variable, ',')
then substring($Variable, 0, length($Variable) -1)
else $Variable

answered
0

Hi

You use the microflow action: "Change Variable” with the following configuration

This removes the last character from your string. 

If you only need to remove it when it is a comma, take a look at this page: https://docs.mendix.com/refguide7/string-function-calls

answered