Check if a string contains ONLY specific characters



I have a string which could contain different text - I’m adding and removing parts of this text with user interactions. At some point, it occurs the string contains only spaces and commas, no meaningful content.

What I want is to check - if the string contains ONLY spaces and commas and no other characters, so I could clear the whole meaningless string, replace it with no text, “”.

Sure I can check with “does not contain” in the condition builder - every character from A to Z, a to z, but it seems to be the longest way ever ))

I wonder if there is a simple solution!

The one suggested by josephxbrick Conditions > Widget contains letters > shorter way was very helpful, but I just can’t figure out how to apply it to my issue.

I guess I can check if my string contains any character from the “ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz”

Maybe there is a special function for it?


Hi @Estel,

I tried a solution using replace() function of the String.

Consider TEXT as local variable for text on widget and use TEXT.replace(’ ‘,’’);
Did a simple POC
Hope it helps.

CheckChars.rp (54.2 KB)


Hi Estel -

I really like @AngryComedian’s solution. Very compact! I was about to post a modified version of my earlier post that you linked to, but I like this one much better because you don’t have to worry about testing the string against every character that’s not a space. (There are more such characters than you might think! Examples: é, ñ, ö, etc.)

Here that same concept extended to include commas in a single expression. If the string contains only spaces and commas, it clears the string being tested.

testString.rp (46.9 KB)


@AngryComedian, @josephxbrick Thanks a lot for your solutions!
While trying to go into them, I understood I did not explain my issue properly.

Issue: There is a list with multiple choice. By checking or unchecking options in this list, I add or remove options (options’ names, indeed) to some other string, dividing them by comma + space.

The problem appears when removing an option - it leaves you with extra commas and extra spaces.

The main part of solution is replace() function applied to every uncheck action. It identifies whether an item is at the beginning of the list or in the middle/end, and makes the trick with commas and spaces.

The only problem is the first item in the string. You check and uncheck options in any order - but, regarding the string, there is always the first item. And if you remove this very first item, the next becomes the first.

There I stumbled. I tracked an order of adding items using another repeater (by adding/removing its rows), but this approach requires non-existing onRowAdded & onRowDeleted events. I tried to link key actions to the 2nd repeater’s checkbox, but it didn’t work correctly.

List to String _estelkhait.rp (95.0 KB)

P.S. The reason I decided to use the text string is because I failed to find pretty solution with horizontal layout of the repeater. The options are of different length so each cell has different width, and repeater widget just denies to adapt to it. Maybe I miss smth with repeater capabilities? (Please let me know if yes).



You can accomplish safe removal of any item with the following expression alone, assuming stringText is a local variable pointing to the text of the rectangle containing the string you are building.

set Text on (rectangle) String to [[stringText.replace(Item.Option + ", ", "").replace(", " + Item.Option, "").replace(Item.Option, "")]]

The first replace() gets rid of the value plus any trailing comma+space, so a middle item or the first item if there are any items after it. The second replace() gets the value when prefixed by comma+space but only if the first replace() fails, so essentially the last item. The third replace gets rid of the value itself (with no comma+space on either side) if the first two replaces fail, so essentially when you’re left with the only item.

Note that this will fail if you have any value that is a substring of another value positioned at the beginning or end of that value. So if you had both “App” and “Apple” you’d run into problems.

Here it is in your file: List to String _estelkhait.rp (88.5 KB)


Many thanks for your involvement @josephxbrick. Actually, I have values like “App” and “Apple” :frowning:

I tried to move forward with your another idea, adjustable row height, and prototyped tags in select box with adjustable width - But a feature of removing tag from input is still a trouble.