Ken Ray wrote:

On 2/28/06 3:57 PM, "Jonathan Lynch" <[EMAIL PROTECTED]> wrote:

I like the idea of using itemdel as a means of counting - very clever...

I was thinking there must be some other immediate means of counting?

How about this one?

function CountChars pString,pChar
 replace space with null in pString
 replace pChar with space in pString
 return ((the number of words of pString)-1)
end CountChars

That doesn't work because a sequence of consecutive spaces doesn't cause intermediate null words - the sequence is a single word delimiter. So if you tried to count the ":"s in "asd:::fgh" you'd replace it to "asd fgh" - which word-counting says is the same as "asd:fgh".

It would also get the wrong answer if there are quotes in the string forming a quoted word. I think it requires a space immediately before the first quote for ti to be considered the start of a quoted word - but once it does form a quoted word, internal spaces are ignored, as is the lack of a space after the second quote.

string             word count
------- ---------- asdfgh 1 as you wanted
asd"extra"fgh      1 again
asd "extra"fgh     3 !!
asd "extra" fgh    3 again
asd "extra"   fgh  3 again


--
Alex Tweedly       http://www.tweedly.net

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 268.1.1/270 - Release Date: 27/02/2006
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to