How to find the offset of the first character in a string that's not a tab?
Ken Ray
kray at sonsothunder.com
Fri Jan 22 17:33:16 EST 2021
> On Jan 21, 2021, at 8:36 AM, Keith Clarke via use-livecode <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.
Email: kray at sonsothunder.com
Website: https://www.sonsothunder.com
>
> Thanks all - I’ve stopped trying to find the syntax for ‘find any char but this’ in offset and instead, taken Dick’s advice to iterate through the chars and count the loops until char <> tab. :)
> Best,
> Keith
>
>> On 21 Jan 2021, at 14:03, Brian Milby via use-livecode <use-livecode at lists.runrev.com> wrote:
>>
>> You could also use matchChunk with a regular expression that excludes the tab character.
>>
>> Sent from my iPhone
>>
>>> On Jan 21, 2021, at 7:14 AM, Keith Clarke via use-livecode <use-livecode at lists.runrev.com> wrote:
>>>
>>> Ah yes indeed, I’d forgotten I could test with 'put not(tab)’ in the message box - that certainly proves the syntax was wrong! :-)
>>> Best,
>>> Keith
>>>
>>>>> On 21 Jan 2021, at 10:49, Dick Kriesel via use-livecode <use-livecode at lists.runrev.com> wrote:
>>>>>
>>>>>
>>>>>
>>>>>> On Jan 21, 2021, at 2:34 AM, Keith Clarke via use-livecode <use-livecode at lists.runrev.com> wrote:
>>>>>
>>>>> I was just keen to understand why offset wasn’t happy with the ‘not(tab)’ in this instance.
>>>>
>>>> expression "not(tab)" evaluates to true, which doesn’t serve your purpose
>>>>
>>>> — Dick
>>>>
>>>>
>>>> _______________________________________________
>>>> use-livecode mailing list
>>>> use-livecode at lists.runrev.com
>>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list