Need help with stringreplace or regex

Get help with using AutoHotkey and its commands and hotkeys
omar
Posts: 462
Joined: 22 Oct 2015, 17:56

Need help with stringreplace or regex

09 Jan 2021, 20:45

In a file, I have strings like this: abeir7pf4tz
All start with 'abei', then followed by 7 random characters.

Examples are:

abeiy7pcfh6
abeih7pkj7p
abeiv7pdl5v
abeia7prr87
abeiy7pjkdg

It looks like the 6th character is a 7 - but not sure if this will always be the case.

What I want to do is delete all occurrences of 11 character strings that start with abei.

I want to read the file contents, delete all occurrences and then replace the file and overwrite with the new content.

What's the best way of doing this?

Thanks.
User avatar
mikeyww
Posts: 5300
Joined: 09 Sep 2014, 18:38

Re: Need help with stringreplace or regex

09 Jan 2021, 21:24

Read the file to a variable, delete the strings and the file, and then FileAppend to a new file.

You can use a Regex like the following.

\babei\w{7}
omar
Posts: 462
Joined: 22 Oct 2015, 17:56

Re: Need help with stringreplace or regex

09 Jan 2021, 21:40

You are amazing 🙂
I'll try that and let you know if I have problems

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], bonswouar, jrachr, MrCheeseman, RayB, TAC109, theon, XMCQCX and 37 guests