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

Brian Milby brian at milby7.com
Thu Jan 21 10:06:30 EST 2021


Just to clarify my suggestion, it isn’t the return value that you would use (other than to check for success), but the third variable in the call that has the position that you would be looking for.

When you say that you are prettifying... are you doing something to adjust each tab in the line?  If so, split may be useful to chunk the data into an array.

And yes, there are many ways to do just about anything.  Glad you found something that works for your situation.

Sent from my iPhone

> On Jan 21, 2021, at 9:38 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. 
> 
> 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