210
Views
5
Comments
How to remove last comma from the string
Question
Application Type
Reactive

Hi ,

In string first check do we have last comma or not if have then remove the last comma from the string.

eg. Table,Chair,Ball, - here last comma remove from this string

2022-07-22 08-49-20
Laura Fidalgo

Hi, you can build a quick logic to get that, using Length() and Substr () built-in functions :)

You can check if your last char is a comma with this:

Substr("String",Length("String")-1,Length("String ")) = "," 

If that's true, you can remove the last comma with this: Substr("String",0,Length("String")-1)


Hope this helps!

2026-03-05 14-21-52
José Pinto

An alternative is using the Text API and try something like this assign:

testString

=

If(String_LastIndexOf(testString,",")= Length(testString)-1,

Substr(testString,0,Length(testString)-1)

,testString)


Regards

JP

2023-03-16 16-29-51
Paulo Rosário

Hello Preeti,

Are you building this string?

If so you can just add the "," before the new word, this way you will never have a "," at the end, just check if the String is empty first, and if it is don't add the "," to the first word.

"table" + ",chair" + ",ball" = "table,chair,ball" 

Just another spin on it :) 

If you are not building the string then I'm sure that Laura´s and José's answers will work for you!

Hope it helps! 

Paulo Rosário

2025-07-31 10-32-21
Vikram garasiya

Here are your solution

character = str.charAt(str.length-1)

if( character == ',')

{

slice(0, str.length - 1) 

}

2024-12-06 20-11-23
João Almeida

Hi,

How can i remove the Last comma on One expression?

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.