gigilihooie Posted December 15, 2008 Share Posted December 15, 2008 I have searched and I found one thing, but it didnt help me. I am wondering, can you use wildcards for it? Example script. $String = "xxxx" _ReplaceStringInFile("ex.txt", $String, GUICtrlRead($Input)) The user can input anything so it will change the "xxxx" to say "1h4d", and then again to "hl8s". Is that possable? PS: I know it needs a GUI, its just an example. Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 15, 2008 Share Posted December 15, 2008 I have searched and I found one thing, but it didnt help me. I am wondering, can you use wildcards for it? Example script. $String = "xxxx" _ReplaceStringInFile("ex.txt", $String, GUICtrlRead($Input)) The user can input anything so it will change the "xxxx" to say "1h4d", and then again to "hl8s". Is that possable? PS: I know it needs a GUI, its just an example. No, _ReplaceStringInFile() does not have any wildcards. You can read the whole file into a string (if less than about 100MB) and use StringRegExpReplace() for that. 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...
gigilihooie Posted December 20, 2008 Author Share Posted December 20, 2008 This isnt really working for me. Maybe im just doing it wrong. When I try, to replace XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX with seri-lser-ials-eria-lser-ials-eria-lser it replaces each X with seri-lser-ials-eria-lser-ials-eria-lser. Any ideas? Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 20, 2008 Share Posted December 20, 2008 This isnt really working for me. Maybe im just doing it wrong. When I try, to replace XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX with seri-lser-ials-eria-lser-ials-eria-lser it replaces each X with seri-lser-ials-eria-lser-ials-eria-lser. Any ideas?Post what you tried. 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...
gigilihooie Posted December 20, 2008 Author Share Posted December 20, 2008 MsgBox(0, "title", StringRegExpReplace("XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX", "[.?*]", "seri-lser-ials-eria-lser-ials-eria-lser")) I have tryed \w, [X] (that wont replace the serial numbers if it needs to be changed). Link to comment Share on other sites More sharing options...
GEOSoft Posted December 20, 2008 Share Posted December 20, 2008 (edited) MsgBox(0, "title", StringRegExpReplace("XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX", "[.?*]", "seri-lser-ials-eria-lser-ials-eria-lser")) I have tryed \w, [X] (that wont replace the serial numbers if it needs to be changed).Does the actual serial number contain only numbers or only alpha characters or a combination of both? Edit: Your RegExp in the example is wrong anyway. $sStr = StringRegExpReplace("XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX", "(.+)", "seri-lser-ials-eria-lser-ials-eria-lser") Which is the same as using StringReplace() Give us an actual example of what you want to do Edited December 20, 2008 by GEOSoft 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...
PsaltyDS Posted December 20, 2008 Share Posted December 20, 2008 (edited) MsgBox(0, "title", StringRegExpReplace("XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX", "[.?*]", "seri-lser-ials-eria-lser-ials-eria-lser")) I have tryed \w, [X] (that wont replace the serial numbers if it needs to be changed). This RegExp pattern finds eight groups of four characters each, separated by dashes: Global $sString = "This is my serial number: 1A2B-3333-4C5D-6666-7E8F-9999-0G1H-2222, " & _ "there are many like it, but this one is mine." Global $sSerial = "seri-lser-ials-eria-lser-ials-eria-lser" ConsoleWrite($sString & @LF) $sString = StringRegExpReplace($sString, "(\w{4}-){7}\w{4}", $sSerial) ConsoleWrite($sString & @LF) Edited December 20, 2008 by PsaltyDS 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...
gigilihooie Posted December 20, 2008 Author Share Posted December 20, 2008 Thankyou very much PsaltyDS. Works great. 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