emendelson Posted November 10, 2011 Share Posted November 10, 2011 I understand how to use StringReplace for simple replacements, but I would be grateful for any help in solving this problem.I want to search a file for a line that beginsOutput=and replace everything to the RIGHT of the equals sign with the contents of a variable.I think I need to use a regular expression search to find the string between "Options=" and the CR/LF at the end of the line and then replace that string or the whole line. But I can't figure out the exact technique.Thanks for any help with this. Link to comment Share on other sites More sharing options...
enaiman Posted November 10, 2011 Share Posted November 10, 2011 _FileReadToArray For every element in that array: If StringLeft($array[$i], 7) = "Output=" Then $array[$i] = "Output="&$myVar EndIf Once this is done, use _FileWriteFromArray to have the new content saved to a new file. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
GEOSoft Posted November 10, 2011 Share Posted November 10, 2011 $sStr = FileRead("Somefile,txt") $sVar = "Some Replacement String" $sStr = StringRegExpReplace($sStr, "(?m:^)(?i)(.*output=).+", "$1" & $sVar) 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...
emendelson Posted November 10, 2011 Author Share Posted November 10, 2011 Both of those solutions are perfect, and it would have been a very long time before I thought of either of them on my own. Many thanks to you both! 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