xcaliber13 Posted October 24, 2017 Posted October 24, 2017 (edited) I am looking for a way to extract text from a file and create a new file with the extracted text. Along with the extracted text no longer in the original file. Example text: H SMUC text text text text text 1 more text more text more text 2 more text 3 more text 4 more text 5 more text H SMUCP text text text text text 1 more text more text more text 2 more text 3 more text 4 more text 5 more text repeats to end of file. I want to extract all text from H SMUCP to end of line 5. I have tried #include <Date.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include <File.au3> #include <String.au3> #include <StringConstants.au3> Global $sFile $selectedfolder = "X:\DEMOS\SRA\SMATemp" $aFileList = _FileListToArray($selectedfolder, "*.txt", $FLTA_FILES) For $i = 1 To $aFileList[0] $afilename = StringMid($aFileList[$i], 52, 11) $tFile = FileRead("X:\DEMOS\SRA\SMATemp\"&$aFileList[$i]) Local $bResults[0] $bResults = StringRegExp($tFile, "(H SMUCP*)\5 ", 3) _ArrayDisplay($bResults) Next Edited October 24, 2017 by xcaliber13 title correction
mikell Posted October 24, 2017 Posted October 24, 2017 ? $aResults = StringRegExp($tFile, "(H\h+SMUCP?.+\R+(?:.+\R*){5})", 3)
xcaliber13 Posted October 24, 2017 Author Posted October 24, 2017 mikell, Just had to change to this: $aResults = StringRegExp($tFile, "(H\h+SMUCP.+\R+(?:.+\R*){5})", 3) And then it pulled the correct data. Thank you Regex will be the death of me yet. Again Thank you
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now