Jump to content

The case of the missing backreferences


Recommended Posts

In v3.2.1.8, the StringRegExpReplace documentation states "$0 - $9) can be used as back-references". However, when I run this script, I get an undeclared variable error:

MsgBox(0, "Regular Expression Replace Test", StringRegExpReplace("Where have all the flowers gone, long time passing?", "([aeiou])", $0))

Also, shouldn't that statement be $1-$9 can be used as backreferences? Does it truly start at 0?

Who else would I be?
Link to comment
Share on other sites

John, does this mean that backreference variables are not actually variables? Example:

MsgBox(0, "Regular Expression Replace Test", StringRegExpReplace("Where have all the flowers gone, long time passing?", "([aeiou])", Asc("$0")))

This does not return the ascii code of the backreferenced variable...

This is actually the same as Asc("$").

Edited by this-is-me
Who else would I be?
Link to comment
Share on other sites

I understand this in regards to the \0-\9 strings, but can you give me an example of what to do if I need to make changes to the replacement string? I specifically want to change all numbers into their ascii equivalents if they are between beginning and ending tags.

In short, I need to edit the replacement data where the replacement data is also the data being found by StringRegExp.

Edited by this-is-me
Who else would I be?
Link to comment
Share on other sites

  • Administrators

I understand this in regards to the \0-\9 strings, but can you give me an example of what to do if I need to make changes to the replacement string? I specifically want to change all numbers into their ascii equivalents if they are between beginning and ending tags.

In short, I need to edit the replacement data where the replacement data is also the data being found by StringRegExp.

No idea. Sounds like you want to edit the data that a back reference contains - don't think that's possible.
Link to comment
Share on other sites

  • Moderators

If you want to modify what is between two tags, just split the string, process the middle, and put it back together. It's a solution.

StringBetween() or _SRE_Between() does this, well you have to make the UDF to combine it, but they retrieve the inbetween marker strings.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...