Count of numbers in a string

Hello,

I have a cell value str="“013188898
013188897
013188896”
I want the count of numbers in this string i.e 3.
How do i get it??

1 Like

If StrVal is your string (e.g. 013188897):

StrVal.Count

Hi @AditiGandhi

You can use below
E.g:
str=“013188898013188897013188896”
result=(str.split(“3”).Length-1).ToString)
It will give you the result (3 is repeated 3 times in the given string)

Thanks,
Siva

@AditiGandhi Can you show us How the Cell Value Appears in Excel, is there a Space in between three numbers?

String value =
013188898
013188897
013188896

expecting each value ending with newlink or enter key
below function will return count-

myString.Split(new String() {Environment.NewLine}, StringSplitOptions.None).Count

@GBK,

Thanks for your reply, but it is giving value 1 instead of 3.

Hi @supermanPunch,
image

The cell value appears like this.

Also how do i get the value in for each loop for each number in the cell.In the above image I want a for each loop for these these numnbers?

you can try to remove count and assign to a string list to check whether string is having a newline or enter.

@AditiGandhi Firstly We need to see how we can Split those three numbers, there must be criteria to Split those Numbers either based on Space or based on NewLine, If either of the Spits Don’t work then that means a Different Approach needs to be used, Have you Checked if we can Split Those Cell Values into 3 values based on Space or New Line ?

Hi Aditi,
you can use this expression: yourstring.Split(Environment.NewLine.ToCharArray).count
Thanks

1 Like

HI @supermanPunch,
The length of each number is 9 digits

here you with an xaml
BlankProcess17.zip (16.1 KB)

Cheers @AditiGandhi