Fun, fun…

So if you collect ALL the opening and closing strings, and hopefully these 
never overlap, then each pair can be “ordered”. Now identifying each is just a 
matter of thinking in terms of “pairs” of offsets. You can then identify each 
by their “paired” position in the forward direction.

Or am i missing it still?

Craig

> On Mar 23, 2023, at 12:29 PM, François via use-livecode 
> <use-livecode@lists.runrev.com> wrote:
> 
> An example of when a backwards search would be useful is the following:
> 
> In the app, you have to find command environments. Environments are delimited 
> by an opening string and a closing string.
> 
> Usually, I search forward for the opening string, then search for the closing 
> string afterwards. Once this occurrence is processed, the app goes on with a 
> forward search.
> 
> Now another problem: I want to see in which environment a text position is 
> in, i.e. finding the enclosing opening and closing strings.
> 
> Looking for the closing string is a no brainer. Looking for the opening 
> string is no more difficult if I can do a backwards search.
> 
> However, if I can only search forward, I must start the search at the 
> beginning of the text to scan all the occurrences of the opening string that 
> stand before the text position (if any). The complexity of this approach is 
> not the same as in the case where a backwards search is available.
> 
> François
> 
>> Le 23 mars 2023 à 16:48, Craig Newman via use-livecode 
>> <use-livecode@lists.runrev.com> a écrit :
>> 
>> Francois.
>> 
>> I am sure you know what you have and what you need.
>> 
>> But just for my curiosity, if I had to do what you want, I would have used 
>> the “offset” function and its “charsToSkip” parameter to find all instances 
>> of the text to find, and then use those values in sequence to work 
>> backwards. But then how do you know when to stop?
>> 
>> Craig
>> 
>>> On Mar 23, 2023, at 11:30 AM, François via use-livecode 
>>> <use-livecode@lists.runrev.com> wrote:
>>> 
>>> The text source is not very big.
>>> 
>>> However I implement transcoding from one language to another and I do an 
>>> VERY large amount of search and replace.
>>> 
>>> I think I have quite optimized my LC code but transcoding can take 5 
>>> minutes to do, and I need the whole process to chase unexpected bugs. This 
>>> is using the forward search (offset) most of the time.
>>> 
>>> Using a standalone app takes the time down to 4 minutes, which is not a 
>>> sufficient gain for my usage.
>>> 
>>> François
>>> 
>>>> Le 23 mars 2023 à 16:21, Craig Newman via use-livecode 
>>>> <use-livecode@lists.runrev.com> a écrit :
>>>> 
>>>> Francois.
>>>> 
>>>> Who wouldn’t?
>>>> 
>>>> But unless you are working with VERY large datasets, I bet a handler would 
>>>> process quickly.
>>>> 
>>>> Craig
>>>> 
>>>>> On Mar 23, 2023, at 10:58 AM, François via use-livecode 
>>>>> <use-livecode@lists.runrev.com> wrote:
>>>>> 
>>>>> @Ben
>>>>> 
>>>>> Too bad…
>>>>> 
>>>>> @ Craig
>>>>> 
>>>>> I would rather have an optimized version, I do a lot of text processing 
>>>>> in my app.
>>>>> 
>>>>> Thanks to both of you!
>>>>> François
>>>>> 
>>>>>> Le 23 mars 2023 à 14:43, Craig Newman via use-livecode 
>>>>>> <use-livecode@lists.runrev.com> a écrit :
>>>>>> 
>>>>>> @Ben.
>>>>>> 
>>>>>> 20 years! Congratulations!.
>>>>>> 
>>>>>> @Francois
>>>>>> 
>>>>>> This can be scripted easily. Do you need help with that?
>>>>>> 
>>>>>> Craig
>>>>>> 
>>>>>>> On Mar 23, 2023, at 8:21 AM, Ben Rubinstein via use-livecode 
>>>>>>> <use-livecode@lists.runrev.com> wrote:
>>>>>>> 
>>>>>>> https://quality.livecode.com/show_bug.cgi?id=584 (20th anniversary this 
>>>>>>> September!)
>>>>>>> 
>>>>>>> Also
>>>>>>> https://quality.livecode.com/show_bug.cgi?id=8353
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> On 23/03/2023 11:35, François via use-livecode wrote:
>>>>>>>> I would like to search for a string within another string, starting at 
>>>>>>>> a given position, but backward.
>>>>>>>> In some languages, you can achieve that by providing a negative number 
>>>>>>>> for the initial position of the search.
>>>>>>>> Is this possible in LiveCode?
>>>>>>>> TIA
>>>>>>>> François
>>>>>>>> _______________________________________________
>>>>>>>> use-livecode mailing list
>>>>>>>> use-livecode@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@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@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@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@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@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@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@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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to