How to find the offset of the first character in a string that's not a tab?

Bob Sneidar bobsneidar at iotecdigital.com
Fri Jan 22 18:58:43 EST 2021


I did not know this! Isn’t anyone else shocked and surprised??

Bob S


On Jan 22, 2021, at 2:33 PM, Ken Ray via use-livecode <use-livecode at lists.runrev.com<mailto:use-livecode at lists.runrev.com>> wrote:

On Jan 21, 2021, at 8:36 AM, Keith Clarke via use-livecode <use-livecode at lists.runrev.com<mailto:use-livecode at lists.runrev.com>> wrote:

Thanks Brian. I looked at matchChunk in the dictionary & it seems to return a boolean, rather than the offset.

The boolean is just whether or not the matchChunk operation was successful; you need to provide variables for the start and end character offsets in the function call:

if matchChunk(myString,"([^\t])",tStart,tEnd) then
 put "The offset to the first non-tab character is:" && tStart
else
 -- matchChunk had an error because the regex was bad or something
end if

I know you've moved on, but just for the record...

:D


Ken Ray
Sons of Thunder Software, Inc.



More information about the use-livecode mailing list