Jump to content

Recommended Posts

Posted

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.

  • Moderators
Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...