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

Keith Clarke keith.clarke at me.com
Thu Jan 21 10:35:49 EST 2021


Ah, thanks, Brian - re-reading more carefully, I see how the first item in the positionVarsList would provide the offset of the first non-tab character.

Re prettification, I’m trying to create a quick & dirty tool to process a set of comma-delimited query strings - to see their common patterns. They have nested label:value pairs, some of which expand further into arrays of varying depth bounded with curly braces & square brackets but they’re not standards-based JSON HTML or XML, so Coda prettification tools can’t won’t recognise and clean them up for me.

It’s (hopefully) a one-off activity, so I’m hoping to get away with quick & dirty text manipulation. I’ve made reasonable progress by iterating through chars but now need to do some post-processing cleanup of the ’tab-nested’ lines - hence the need to count the tab indentations.

I try to avoid arrays, as I can’t see the workings! :-D
Best,
Keith      

> On 21 Jan 2021, at 15:06, Brian Milby via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> 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
> 
> _______________________________________________
> 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