How to Remove commas from a string?

I want to remove all commas from a string.

I am using the stripchar( function.

Here is the code:

  LAddressMinusComma= stripchar(LAddress,"AZaz09—- ..")

My intent is to keep all letters A to Z and a to z, dash (-), periods, numbers and spaces.

Commas are retained.

I am on Apple Silicon running Ventura. Apple M1 Max.

When I try on my MacProBook Lap Top running on Intel there is no problem.

Methinks we have a bug.


I only count one space in your formula, so it is probably being paired with the period that follows. A comma lies between space and period.

If you just want to remove ONE character from a string and leave everything else alone, I think it would be easier to use the replace( function rather than stripchar(.

LAddressMinusComma = replace(LAddress,",","")

If you do want to use stripchar(, I think Dave has the correct fix for you.

Hi Dave,

No, I had the correct spaces. However when I tried it on the older machine I just typed the formula in and did the sequence different and it worked. But NOT the exact formula.

On both OS here is my summary:

Does not work
«Sub Category»=stripchar(«Category»,“AZaz09 —-…”)

This works on both machines with different OS, Ventura & Monterey
«Sub Category»=stripchar(«Category»,“AZaz…-- 09”)

So indeed your suspicion of the spaces and the periods are getting confused.

I’ll take Jim’s advice.

Thank you both.

I can’t leave this un-responded to. As far as I can tell, neither of your formulas work. Nor would I expect them to.

You can’t use ranges in the stripchar( function without understanding the ordering of Unicode characters. Let’s take your first example:

AZaz09 —-…

The first pair is


That’s easy, it matches letters from A to Z. az and 09 are also simple.

The fourth pair in your formula is a space followed by a —. This is going to match everything from space (value of 32) to — (value of 8212). In other words, this will match thousands and thousands of characters, including comma, which has a value of 44. So commas definitely won’t be stripped out.

Your final pair is - (value of 45) to (value of 8230). So overall, this formula will only strip out values below space (invisible control characters) and above 8230 (assorted rare unicode characters). It definitely won’t strip out commas.

If you don’t know what the value of a character is, you can use the asc( function to find out. The Formula Workshop is handy for this.

Your final formula, AZaz…-- 09, also doesn’t work for me. It contains two “reversed” pairs.

The first reversed pair is (value of 8230) to - (value of 45). Since value of the first character of the pair is greater than the value of the second character, this pair is “empty”.

The second reversed pair is - (value of 45) to space (32). Again, the pair is “empty” because the first value is higher.

Always make sure that the first character in each pair has a lower unicode value than the second character in the pair.

Actually, the fact that he didn’t format those formulas as code is complicating things. If I open his post for editing, and copy the formulas from there, the first formula is

stripchar(«Category»,"AZaz09  —-..")

and the second is

stripchar(«Category»,"AZaz..--  09")

When I apply those formulas to


The first formula returns


and the second returns


Aha, good catch Dave, I didn’t think of that. That produces a different formula and different results from just copying the text from the web page. Interestingly, when you pasted it back into the forum as code, that seems to produce the correct result. Yet another reason to ALWAYS indent formulas and code by 4 spaces when pasting them into the forum. For procedures you can easily do that automatically by using the Source>Copy Indented Code menu command.

Thank Jim, Dave

I actually keyed “-” “-”, twice, the key to the right of the numeral zero.

It looks like this"–"

In my simple mind it is no different to"…"
Two periods. “.” then “.”
A range of from “-” to “-”
Or a range of from “.” to “.”

Perhaps something getting screwed up because I am editing from pages. Also tried from Word.

I have even edited within the procedure. No difference.
I was not intentionally going in reverse.

I appreciate your comments and will work around this with the Replace but TRULY, I was not working in reverse.

I simply want to retain the"-".

I will implement your suggestions.

I feel that I am innocent but if found guilty I prefer a Blond to a Blindfold and cigarette.

I have solved the issue with Jim’s suggestion of the Replace( function but trust me, don’t copy my code, just type it in.

Thanks for your time. It remains a mystery to me.

Happy New Year.

It looks like Pages was partly responsible, and Markdown formatting is responsible for some of it. When I open your post for editing, so that I can see the text in its raw form, your two hyphens in the first formula appear as an em dash followed by a hyphen. That was probably Pages that altered it, because that’s the way it appears even in raw form. The two periods that became an ellipsis was the work of the Markdown formatting used by Discourse.

That’s Markdown at work. It converted your two hyphens into an en dash.

As Jim said above, it’s a very good idea to format formulas and code by indenting 4 spaces. In addition to the problems above, Markdown uses asterisks to indicate bold or italic, which could cause asterisks that are used for multiplication to disappear.

If you are editing code outside of Panorama, it’s best to stick to a text editor, rather than a word processor. You don’t want a word processor screwing up your code while trying to make it look pretty.

1 Like

Not a question of guilty, I just wanted to clarify how the stripchar( function works both for you and for anyone that may read this thread later.

No – this is the road to utter confusion. If everyone is typing the code over and over again there is too much opportunity for mistakes. To collaboratively work on a problem, we need to make sure that we are all working with the same code. Copy and paste are the only way to ensure that, but you should only use plain text editors, and always indent code by 4 spaces when pasting into the forum, to make sure that the forum itself doesn’t alter the code.

Ok, now I do think you are guilty! :rofl: I would recommend that you never edit code in a word processor. Word processors are not designed for editing text. Panorama has pretty good text editing for code, so that’s usually the best bet. If you feel you MUST use some other editor, then stick to plain text editors like BBEdit, TextMate or VSCode. Do NOT use a program that supports different text styles, like Word, Pages, Numbers, etc.