regex backreferences

Kaveh kaveh at rivervalleytechnologies.com
Wed Dec 15 04:46:36 EST 2021


This is a major shortcoming and I have wanted this for years. Thierry has
filled the gap with his excellent SunnyRex library
<https://sunny-tdz.com/livecode/sunnyrex>. I have used it successfully, I
recommend it, and it works well. He has also supported me well after I
purchased SunnyRex. But it is a proprietary dependency and that is
something at the back of my mind.

It would be great if LiveCode could add this feature. Or perhaps come to an
agreement with Thierry so that we reduce dependencies.

Regards
Kaveh

On Wed, 15 Dec 2021 at 03:42, J. Landman Gay via use-livecode <
use-livecode at lists.runrev.com> wrote:

> I wish it did, but replaceText doesn't support back references. The
> parameters at the end are treated as literals, whether as actual quoted
> literals or variables containing a value.
>
> If there isn't a feature request for it, there should be.
> --
> Jacqueline Landman Gay | jacque at hyperactivesw.com
> HyperActive Software | http://www.hyperactivesw.com
> On December 14, 2021 6:03:12 PM Devin Asay via use-livecode
> <use-livecode at lists.runrev.com> wrote:
>
> > Hi all,
> >
> > Does the replaceText() function allow the use of backreferences to
> retain
> > groupings of text between matches. For example, if I have some text like
> this:
> >
> > <p><span style=‘cruft'>Good stuff here.</span></p>
> >
> > I want to end up something like this:
> >
> > <h1>Good stuff here.”</h1>
> >
> > In BBedit I can search for <p><span style=“cruft”>(.*)</span></p> and
> > replace it with <h1>\1</h1> and it preserves the run of text designated
> by
> > parentheses.
> > (I know, I can get more fancy on matching the runs of html tags, but I’m
> > mainly interested in retaining the text, not in regex madness.)
> >
> > In LC this does not work:
> >
> >   put replaceText(myText,"<p><span
> >   style=“cruft”>(.*)</span></p>”,”<h1>\1</h1>”) into myText
> >
> > I just end up with <h1>\1</h1>, when I want <h1>Good stuff here.</h1>
> >
> > Can replaceText even do this?
> >
> > - Devin
> >
> >
> > Devin Asay
> > Office of Digital Humanities
> > Brigham Young University
> >
> > _______________________________________________
> > 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
>


-- 
Kaveh Bazargan PhD
Director
River Valley Technologies <http://rivervalley.io> ● Twitter
<https://twitter.com/rivervalley1000> ● LinkedIn
<https://www.linkedin.com/in/bazargankaveh/> ● ORCID
<https://orcid.org/0000-0002-1414-9098>
*Accelerating the Communication of Research*


More information about the use-livecode mailing list