Multiple commas in one string


My string contains multiple commas like this

625 State St., PO Box 2207
Schenectady**,** NY 123012207

and one more string contains single comma like this

PO Box 740801
Atlanta**,** GA 30374

How can i loop into the condition(if or else), if multiple commas it should be in one flow and other flow if it is a single comma?

Hello @hairsh,

Hope this could help you:

A quick solution could be using the following to get the number of commas:
int32 countCommas = yourstring.Count(Function(c As Char) c = “,”)

Thanks and best regards,

Another solution is

int count = yourString.Split(',').Length - 1

if count == 1 {}
if count > 1 {}

getting error like this

Hi @hairsh,

On your split use (","c).



You need to specify the character type like below -

int count = yourString.Split(","c).Length - 1

1 Like

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