this-is-me Posted October 11, 2006 Share Posted October 11, 2006 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 More sharing options...
Administrators Jon Posted October 11, 2006 Administrators Share Posted October 11, 2006 "$0" Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
this-is-me Posted October 11, 2006 Author Share Posted October 11, 2006 (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 October 11, 2006 by this-is-me Who else would I be? Link to comment Share on other sites More sharing options...
Administrators Jon Posted October 11, 2006 Administrators Share Posted October 11, 2006 No they are not variables, they are strings. The "replacement" parameter is a string. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Administrators Jon Posted October 11, 2006 Administrators Share Posted October 11, 2006 Example: MsgBox(0, "", StringRegExpReplace("April 15, 2003", "(\w+) (\d+), (\d+)", "$1 1st, $3")) Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
this-is-me Posted October 11, 2006 Author Share Posted October 11, 2006 (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 October 11, 2006 by this-is-me Who else would I be? Link to comment Share on other sites More sharing options...
Administrators Jon Posted October 12, 2006 Administrators Share Posted October 12, 2006 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. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
this-is-me Posted October 12, 2006 Author Share Posted October 12, 2006 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? Link to comment Share on other sites More sharing options...
Richard Robertson Posted October 12, 2006 Share Posted October 12, 2006 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. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 12, 2006 Moderators Share Posted October 12, 2006 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 More sharing options...
jpm Posted October 15, 2006 Share Posted October 15, 2006 I move it to support forum as it is no more a "Bug report" Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now