I have a text file that has lines of paths
C:\Docs\nine\nine^01"some text to end of line"
C:\Docs\nine\nine^02"some text to end of line"
C:\Docs\seven\seven^1"some text to end of line"
C:\Docs\seven\seven^2"some text to end of line"
so if I have a needle "seven^" and it has 1 or two digits after it, I want those and the rest of the line
I want to add each instance to a new line in a string:
nine^01some text
nine^01some text
Matching String in Text File Lines
Re: Matching String in Text File Lines
Code: Select all
#Requires AutoHotkey v1.1.33
filePath := A_ScriptDir "\test.txt"
str := ""
If FileExist(filePath)
Loop Read, % filePath
RegExMatch(A_LoopReadLine, ".*\\\K.+\^\d{1,2}.*", m) && str .= (str = "" ? "" : "`n") m
Else MsgBox 48, Error, % "File not found.`n`n" filePath
MsgBox 64, Result, % str
Who is online
Users browsing this forum: mstrauss2021, william_ahk and 366 guests