Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to count how many times a character(0) appears in a string

I'm looking for a way of counting how many times 0 will apear in a string like 3000.

I'll use it to complete my scientific notation calculator.

I know there are some parts missing, specially the negative numbers but here it is what I got til now.



display dialog "Big Number" default answer ""

set nB to text returned of result

set fnB to first character of nB as integer

set nZ to (last character of nB) / fnB as integer

if nZ = 0 then

repeat while nB ≥ 10

set nB to nB / 10

end repeat

end if

set s1 to " X 10"

set nB to nB as string

display dialognB & s1

Mac mini

Posted on Mar 6, 2014 6:38 PM

Reply
1 reply

How to count how many times a character(0) appears in a string

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.