On Fri, Feb 24, 2012 at 3:48 AM, Sumner, Walt wrote:
> Here's a small speed increment, still no repeat loops except for 3 or 4
> hidden within Livecode. Counts "pp" as 3 "pp", not 5.
>
> I've had a look at this and generally don't agree that there are only 3
"pp" in "pp". I accept that in
Ohhh... sexier!
Bob
On Feb 23, 2012, at 10:10 AM, Ken Ray wrote:
>
> On Feb 22, 2012, at 9:46 PM, Bob Sneidar wrote:
>
>> only works for single characters.
>>
>> function substringCount pString, pChunk
>> replace pString with cr & pString & cr in pChunk
>> filter pChunk with pString
>> retu
e number of lines of pChunk
end substringCount2
OUTPUT
dividing: 35
filtering: 56
6 6 true
Walt
On Wed, Feb 22, 2012 at 8:47 PM, Bob Sneidar wrote:
Message: 22
Date: Wed, 22 Feb 2012 19:46:23 -0800
From: Bob Sneidar
To: How to use LiveCode
Subject: Re: Get number of occurrences of one strin
On Feb 22, 2012, at 9:46 PM, Bob Sneidar wrote:
> only works for single characters.
>
> function substringCount pString, pChunk
> replace pString with cr & pString & cr in pChunk
> filter pChunk with pString
> return the number of lines of pChunk
> end substringCount
Here's one that works i
;>> repeat for each char theChar in pString
>>>if theChar is pChar then
>>> add 1 to theCount
>>>end if
>>> end repeat
>>> return theCount
>>> end substringCount
>>>
>>>
>&g
eidar
To: How to use LiveCode
Sent: Wed, Feb 22, 2012 10:49 pm
Subject: Re: Get number of occurrences of one string in another
I am everyone's Uncle. Still, no repeat loops needed. See my solution.
Bob
On Feb 22, 2012, at 7:44 PM, Jerry Jensen wrote:
> The offset() function has a th
012, at 7:37 PM, Andrew Kluthe wrote:
> >>>
> >>>> function substringCount pChar, pString
> >>>> put 0 into theCount
> >>>> repeat for each char theChar in pString
> >>>>if theChar is pChar then
> >>>>
ar is pChar then
>>>> add 1 to theCount
>>>>end if
>>>> end repeat
>>>> return theCount
>>>> end substringCount
>>>>
>>>>
>>>&g
Interesting, doesn't work the way I'd expect with find either. Seems like
looking for pp in pp would find 5 matches. So I guess offset() would
be the way to go if you don't want this eliminative affect.
___
use-livecode mailing list
use-livecode@list
eCount
> >> end substringCount
> >>
> >>
> >> Would work out nicely if there is not built in function for this.
> >>
> >> --
> >> View this message in context:
> http://runtime-revolution.278305.n4.nabble.com/Get-number-of-occurr
>> add 1 to theCount
>> end if
>>end repeat
>>return theCount
>> end substringCount
>>
>>
>> Would work out nicely if there is not built in function for this.
>>
>> --
>> View this message in context:
>&
There are several ways to do this i'm sure.
If you want to search a field you can use find in a function for the task
-- I put this in a button. Find empty ensures we start at the beginning of
the field.
-- the repeat loop goes until the findit function returns false, adding 1
to the total each
out nicely if there is not built in function for this.
>
> --
> View this message in context:
> http://runtime-revolution.278305.n4.nabble.com/Get-number-of-occurrences-of-one-string-in-another-tp4412675p4412707.html
> Sent fr
f there is not built in function for this.
>
> --
> View this message in context:
> http://runtime-revolution.278305.n4.nabble.com/Get-number-of-occurrences-of-one-string-in-another-tp4412675p4412707.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
>
>
in function for this.
--
View this message in context:
http://runtime-revolution.278305.n4.nabble.com/Get-number-of-occurrences-of-one-string-in-another-tp4412675p4412707.html
Sent from the Revolution - User mailing list archive at Nabble.com.
___
use
Is there any way, in the native LiveCode language, to check for the number of
occurrences of one string in another? FOr example:
put substringCount( "p", "apple" )
// returns 2
just curious
Thanks!
___
use-livecode mailing list
use-livecode@lists.run
16 matches
Mail list logo