Jump to content
Sign in to follow this  

Find a sentence and remove

Recommended Posts

I am looking for a way to search a text file for the start of a sentence


Tunnel command:


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

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

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)

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

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...