regex backreferences

Devin Asay devin_asay at byu.edu
Tue Dec 14 19:00:48 EST 2021


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



More information about the use-livecode mailing list