Sign in to follow this  
Followers 0
this-is-me

The case of the missing backreferences

11 posts in this topic

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?

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

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?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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?

Share this post


Link to post
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.

No idea. Sounds like you want to edit the data that a back reference contains - don't think that's possible.

Share this post


Link to post
Share on other sites

Would it be possible to make the backreferences available to a macro? I can see great possibilities if the backreference can be edited before replacement.


Who else would I be?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

[center]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.[/center]

Share this post


Link to post
Share on other sites

I move it to support forum as it is no more a "Bug report"

Share this post


Link to post
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
Sign in to follow this  
Followers 0