TecGuy 0 Posted April 13, 2010 I am looking for a way to search a text file for the start of a sentence eg. Tunnel command: and Command to run: The beginning of each sentence begins the same. What would be the easiest way to accomplish this. I will have more than just the two sentences. BTW there could be multiple sentences that start the same way and I will need to remove them all. Share this post Link to post Share on other sites
JohnOne 1,603 Posted April 13, 2010 The best way would be to use the StringRegExp()or StringRegExpReplace() functions. Unfortunately I am lousey at making patterns still, but it wont harm you to have a look, you will most likely be better at it than I. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Share this post Link to post Share on other sites
SmOke_N 211 Posted April 13, 2010 You could use StringRegExpReplace but you need an ending character for the sentence ( like some type of punctuation ).Example, if all your sentences end in a period:Global $s_infile = "filename to read" Global $s_outfile = "filename to write to, could be the same as in file" Global $s_string = FileRead("filename") $s_string = StringRegExpReplace($s_string, "(?i)(?s)Tunnel command:.+?\.", "") $s_string = StringRegExpReplace($s_string, "(?i)(?s)Command to run:.+?\.", "") Global $h_open = FileOpen($s_outfile, 2) FileWrite($h_open, $s_string) FileClose($h_open)Be sure to use this code on a test file only. 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. Share this post Link to post Share on other sites
TecGuy 0 Posted April 13, 2010 Thanks. Will try it out. Share this post Link to post Share on other sites