computergroove Posted January 11, 2011 Share Posted January 11, 2011 I have an xml file with the string "/merchant/poslogin.php?key=20000209_432</url>" and my script changes the value of 20000209_432. If I need to change it again I want to search for the string "/merchant/poslogin.php?key=" and tell autoit to count 27 characters from the string and replace the next 12 digits with my inputbox value. How can I tell StringReplace to start 27 digits from the string being replaced? $NewCustomerID = StringReplace($chars, "2000293", $CustomerID) <-- Here $NewCustomerPin = StringReplace($NewCustomerID, "432", $CustomerPin) FileOpen("tiapp.xml", 2) FileWrite("tiapp.xml", $NewCustomerPin) FileClose($xmlfile) Exit Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
somdcomputerguy Posted January 11, 2011 Share Posted January 11, 2011 I believe the StringTrimRight() function will do some good here. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
computergroove Posted January 11, 2011 Author Share Posted January 11, 2011 (edited) OK that worked out good. Here is my final code: $NewCustomerID = StringReplace($chars, 553, $CustomerID) ;Repaces the Customer ID in tiapp.xml $NewCustomerData = StringReplace($NewCustomerID, 562, $CustomerPin) ;NewCustomerData hold the properly modified xml data FileOpen("tiapp.xml", 2) FileWrite("tiapp.xml", $NewCustomerData) FileClose($xmlfile) Exit Edited January 11, 2011 by computergroove Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
JohnOne Posted January 11, 2011 Share Posted January 11, 2011 heres another way. #include <String.au3> $sString = "/merchant/poslogin.php?key=20000209_432</url>" $sID = _StringBetween($sString,"key=","</url>") $sNewString = StringReplace($sString,$sID[0],"newKey") MsgBox(0,"",$sNewString) AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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