Armand Posted March 17, 2008 Share Posted March 17, 2008 $str = ""HTMLtextHERE"</a> (1993)" $FormedTitle = StringRegExpReplace($str, "(&#(\d+);)", Chr(Number('\2'))) ConsoleWrite("Result:"&$FormedTitle) why does the above script not working as should ?! -> Using the "'\2'" as back reference should retrieve the number 34 which should then be converted to '"' by the Chr() function. Any help will be appreciated, THAnks in advance ! [u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?! Link to comment Share on other sites More sharing options...
weaponx Posted March 17, 2008 Share Posted March 17, 2008 Well it would help if you explained the goal of the script. First major problem is you can't nest double quotes within double quotes, or single quotes within single quotes. Quotes either need to be mixed (single outside, double inside OR double outside, single inside) or escaped.http://www.autoitscript.com/autoit3/docs/i...g_datatypes.htm Link to comment Share on other sites More sharing options...
pacman1176 Posted March 17, 2008 Share Posted March 17, 2008 (edited) MsgBox(1,"",Chr(Number('\2'))) Returns a whole lotta nothin. MsgBox(1,"",Number("/2")) Returns zero. Is this the output you wished to have? And it's kind of hard to tell, but what are you trying to replace exactly. can't nest double quotes within double quotesI think Armand meant $str = "'HTMLtextHERE'</a> (1993)" but a simple typo or overlook, just using an example. Edited March 17, 2008 by pacman1176 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 17, 2008 Moderators Share Posted March 17, 2008 (edited) Not quite sure where your thinking is in this... but you can't pass a function to the RegExp Replace function.Any conversions to the return will have to be mad after the fact.Are you sure that just using:$FormedTitle = StringRegExpReplace($str, "(&#(\d+);)", '\2')Even returns what you think it does?Edit:Damn Wink gif in the expression! Edited March 17, 2008 by SmOke_N 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...
Armand Posted March 17, 2008 Author Share Posted March 17, 2008 BAHHH guys, i didn't miss-wrote it... it's just that this "Edit Box" is also using PHP/HTML scripts and thus it showed my:& # 34;*** Spaces added between each char.into '"' and that's why you guys couldn't understood what i was asking anyhow, @SmOke_N if i can't use functions inside the regular expression, can you think about any other way to transcribe these HTML aschii codes into normal letters ?! [u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?! Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 17, 2008 Moderators Share Posted March 17, 2008 BAHHH guys, i didn't miss-wrote it... it's just that this "Edit Box" is also using PHP/HTML scripts and thus it showed my: & # 34; *** Spaces added between each char. into '"' and that's why you guys couldn't understood what i was asking anyhow, @SmOke_N if i can't use functions inside the regular expression, can you think about any other way to transcribe these HTML aschii codes into normal letters ?!You'll have to change each one individually: $sString = StringReplace($sString, """, "Whatever") etc... 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...
PsaltyDS Posted March 17, 2008 Share Posted March 17, 2008 BAHHH guys, i didn't miss-wrote it... it's just that this "Edit Box" is also using PHP/HTML scripts and thus it showed my: & # 34; *** Spaces added between each char. into '"' and that's why you guys couldn't understood what i was asking anyhow, @SmOke_N if i can't use functions inside the regular expression, can you think about any other way to transcribe these HTML aschii codes into normal letters ?! Please post the entire RegExp string with a space between each character, so I can see the whole string you meant to use (not just the fragment above). It also might work if you put the string in code tags (vice AutoIt tags). You can embed functions as part of assembling your RegExp string, and what finally gets processed with be the string assembled from the return values of those functions. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 17, 2008 Moderators Share Posted March 17, 2008 Please post the entire RegExp string with a space between each character, so I can see the whole string you meant to use (not just the fragment above). It also might work if you put the string in code tags (vice AutoIt tags). You can embed functions as part of assembling your RegExp string, and what finally gets processed with be the string assembled from the return values of those functions. I'll iterate what PsaltyDS and I said with an example below. Functions are processed from Right to Left... So any function that is inside a function is processed before the next left function: Example:MsgBox(64, "Information", MsgBox(36, "Question", "Did you know it worked like this?"))You'll see the "Question" MsgBox first... Then the MsgBox "Information", in the Text portion of MsgBox "Information", you'll see the return value of MsgBox "Question". 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...
Armand Posted March 17, 2008 Author Share Posted March 17, 2008 @SmOke_N i've fully understood what he said but that's the opposite of what you've said before: Not quite sure where your thinking is in this... but you can't pass a function to the RegExp Replace function. anyhow this is my code as i meant it to be: PS. i think the issue is with the backward reference of the string-reg-exp '\2' which is being transfered as is... $str = ""HTMLtextHERE"</a> (1993)" $FormedTitle = StringRegExpReplace($str, "(&#(\d+)wink.gif", Chr(Number('\2'))) ConsoleWrite("Result:"&$FormedTitle) And again with spaces added: $str = "& # 34; HTMLtextHERE & # 34;</a> (1993)" $FormedTitle = StringRegExpReplace($str, "(&#(\d+)wink.gif", Chr(Number('\2'))) ConsoleWrite("Result:"&$FormedTitle) [u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?! Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 17, 2008 Share Posted March 17, 2008 @SmOke_N i've fully understood what he said but that's the opposite of what you've said before: anyhow this is my code as i meant it to be: PS. i think the issue is with the backward reference of the string-reg-exp '\2' which is being transfered as is... $str = ""HTMLtextHERE"</a> (1993)" $FormedTitle = StringRegExpReplace($str, "(&#(\d+);)", Chr(Number('\2'))) ConsoleWrite("Result:"&$FormedTitle) And again with spaces added: $str = "& # 34; HTMLtextHERE & # 34;</a> (1993)" $FormedTitle = StringRegExpReplace($str, "(&#(\d+);)", Chr(Number('\2'))) ConsoleWrite("Result:"&$FormedTitle) Ahh. I thought you were calling functions to assemble the RegExp string. You really want to pass the back reference to to some functions and have the result become the replacement string. I totally did not get that before. We're back to what SmOke_N said to begin with: I don't think you can't do that. I think what you are getting is Number('\2') = 0, passed to Chr(0) = NUL, so the replacement string is a NUL character. P.S. I got the wink.gif out of there by unchecking "Enable emoticons" at the bottom of the editor, but the funky URL-encode is still boogered. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 17, 2008 Moderators Share Posted March 17, 2008 @SmOke_Ni've fully understood what he said but that's the opposite of what you've said before:How is it the opposite? You CAN'T pass a function to StringRegExp PERIOD.I demonstrated to you with the message box's what is actually being sent (the processed function before the back reference is initiated)... Thus nulling out the back reference all together.Number("/2") = 0Chr(0) = NULLWhen you think you are sending... "/2"You're sending NULL because the function Chr(Number("/2")) has already been processed before the replacement has been attempted. 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...
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