Code: Select all
TF_RegExReplace("!" A_LoopFileFullPath,"im)\b" trim(A_LoopReadLine,"`r`n") "\b","lock") ; use trim to remove trailing new line chars which may interfere
Code: Select all
TF_RegExReplace("!" A_LoopFileFullPath,"im)\b" trim(A_LoopReadLine,"`r`n") "\b","lock") ; use trim to remove trailing new line chars which may interfere
Code: Select all
FileDelete, tftestfile123.txt
FileAppend,
(
01 AutoHotkey is a free, open-source utility for Windows. With it, you can:
02 - Automate almost anything by sending keystrokes and mouse clicks.
03 - Create hotkeys for keyboard, joystick, and mouse. Virtually any key, button, or combination can become a hotkey.
04 - Expand abbreviations as you type them. For example, typing "btw" can automatically produce "by the way".
05 - Create custom data-entry forms, user interfaces, and menu bars. See GUI for details.
06 - Remap keys and buttons on your keyboard, joystick, and mouse.
07 - Respond to signals from hand-held remote controls via the WinLIRC client script.
08 - Convert any script into an EXE file that can be run on computers that don't have AutoHotkey installed.
), tftestfile123.txt
; TF_Find(FilePath, "", "", "i)\Q" SearchText "\E")
MsgBox % TF_Find("tftestfile123.txt", "", "", "abbreviations") ; remember it is case sensitive by default
MsgBox % TF_Find("tftestfile123.txt", "", "", "and",0) ; return a CSV list of all lines with 'and'
MsgBox % TF_Find("tftestfile123.txt", "5", "", "AutoHotkey") ; start at line 5 so it skips the first result e.g. line 1 here
myvar:="autohotkey" ; lowercase
MsgBox % TF_Find("tftestfile123.txt", "", "", "i)\Q" myvar "\E",0,1) ; return the text of all found lines
It shall result in:Am 22.11.2018 um 12:36 schrieb "[email protected]" <[email protected]>:
...
Am 11.10.2018 um 11:11 schrieb "[email protected]" <[email protected]>:
...
with -----Original-Message----- inserted.-----Original-Message-----
Am 22.11.2018 um 12:36 schrieb "[email protected]" <[email protected]>:
...
-----Original-Message-----
Am 11.10.2018 um 11:11 schrieb "[email protected]" <[email protected]>:
...
Code: Select all
FileDelete, tf-testemail.txt ; create a test file
FileAppend,
(
Am 22.11.2018 um 12:36 schrieb "[email protected]" <[email protected]>:
lorem impsum
Am 11.10.2018 um 11:11 schrieb "[email protected]" <[email protected]>:
doler factum
), tf-testemail.txt
TF_RegExReplace("tf-testemail.txt","iUm)^Am (\d{1,2})\.(\d{1,2})\.(\d{4})","-----Original-Message-----`nAm $1.$2.$3")
; now you should have a file tf-testemail_copy.txt which looks like you want it, if you use TF_RegExReplace("!tf-testemail.txt",.... it will OVERWRITE the source file
Code: Select all
TF_RegExReplace(Clipboard,"iUm)^Am (\d{1,2})\.(\d{1,2})\.(\d{4})","-----Original-Message-----`nAm $1.$2.$3")
Code: Select all
Clipboard=
(join`r`n
Am 22.11.2018 um 12:36 schrieb "[email protected]" <[email protected]>:
lorem impsum
Am 11.10.2018 um 11:11 schrieb "[email protected]" <[email protected]>:
doler factum
)
clipboard:=TF_RegExReplace(clipboard,"iUm)^Am (\d{1,2})\.(\d{1,2})\.(\d{4})","-----Original-Message-----`nAm $1.$2.$3")
MsgBox % Clipboard
Code: Select all
clipboard:=RegExReplace(clipboard,"iUm)^Am (\d{1,2})\.(\d{1,2})\.(\d{4})","-----Original-Message-----`nAm $1.$2.$3")
Return to “Scripts and Functions”
Users browsing this forum: Google [Bot] and 47 guests