personant Posted June 4, 2011 Share Posted June 4, 2011 (edited) I'm new in autoit...so how to replace string between fexp= and &algorithm to 907605for an example : before = fexp=1234,5678&algorithmafter = fexp=907605&algorithmplease help me... Edited June 4, 2011 by personant Link to comment Share on other sites More sharing options...
Shaarad Posted June 4, 2011 Share Posted June 4, 2011 $stringold="1234,5678&algorithm" $string=StringTrimLeft ($stringold,10) $stringnew="907605" & $string 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...
Shaarad Posted June 4, 2011 Share Posted June 4, 2011 hope it works 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...
Shaarad Posted June 4, 2011 Share Posted June 4, 2011 $input=inputbox("title","prompt") $string=$input & "&algorithm" This can be done too... 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...
personant Posted June 4, 2011 Author Share Posted June 4, 2011 $stringold="1234,5678&algorithm" $string=StringTrimLeft ($stringold,10) $stringnew="907605" & $string the 1234,5678 is just an example.... the string between the text could be short or long, so the trim script would not work Link to comment Share on other sites More sharing options...
Shaarad Posted June 4, 2011 Share Posted June 4, 2011 yes....so what about the second script... ? 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...
personant Posted June 4, 2011 Author Share Posted June 4, 2011 yes....so what about the second script... ?I want it to be automatic... Link to comment Share on other sites More sharing options...
Shaarad Posted June 4, 2011 Share Posted June 4, 2011 $original="1234,5678&algorithm" $pos=stringinstr ($original,"&algorithm",0) $replacment="907605" $new=$replacment & stringtrimleft ($original,$pos-1) 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...
Shaarad Posted June 4, 2011 Share Posted June 4, 2011 does '&algorithm' always come at the end of the string ?? if yes, the above script can be used 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...
personant Posted June 4, 2011 Author Share Posted June 4, 2011 like I just said... the string between the text could be anything... so I need an universal script Link to comment Share on other sites More sharing options...
Shaarad Posted June 4, 2011 Share Posted June 4, 2011 (edited) $original="1234,5678&algorithm" $pos=stringinstr ($original,"&algorithm",0) $replacment="907605" $new=$replacment & stringtrimleft ($original,$pos-1) almost works as a universal script if you have '&algorithm' at the end... just change $original to any other variable text with '&algorithm' at the end and $replacement with other number and it works as you required... Edited June 4, 2011 by Shaarad 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...
UEZ Posted June 4, 2011 Share Posted June 4, 2011 $before = "fexp=1234,5678&algorithm" $replace_with = "907605" $after = StringReplace(StringRegExpReplace($before, "(fexp=)(.*)(&algorithm)", "$1 " & $replace_with & "$3"), "= ", "=") MsgBox(0, "Test", $after) $after = StringReplace($before, StringMid($before, 6, StringInStr($before, "&algorithm") - 6), $replace_with) MsgBox(0, "Test", $after) Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Shaarad Posted June 4, 2011 Share Posted June 4, 2011 I need to work hard on the StringRegExp and StringRegExpReplace... 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...
personant Posted June 4, 2011 Author Share Posted June 4, 2011 $before = "fexp=1234,5678&algorithm" $replace_with = "907605" $after = StringReplace(StringRegExpReplace($before, "(fexp=)(.*)(&algorithm)", "$1 " & $replace_with & "$3"), "= ", "=") MsgBox(0, "Test", $after) $after = StringReplace($before, StringMid($before, 6, StringInStr($before, "&algorithm") - 6), $replace_with) MsgBox(0, "Test", $after) Br, UEZ Thanks UEZ for the script.. works like a charm Link to comment Share on other sites More sharing options...
sahsanu Posted June 4, 2011 Share Posted June 4, 2011 $after = StringReplace(StringRegExpReplace($before, "(fexp=)(.*)(&algorithm)", "$1 " & $replace_with & "$3"), "= ", "=") Just a little modification to avoid the first StringReplace $after = StringRegExpReplace($before, "(fexp=)(.*)(&algorithm)", "${1}" & $replace_with & "$3") Link to comment Share on other sites More sharing options...
UEZ Posted June 4, 2011 Share Posted June 4, 2011 @sahsanu: that's what I searched for ${1} and used the StringReplace as a workaround!Thanks for it!Br,UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
GEOSoft Posted June 4, 2011 Share Posted June 4, 2011 I need to work hard on the StringRegExp and StringRegExpReplace... There is a tool in my signature to help you with that. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" 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