Jump to content

Text extraction help


Recommended Posts

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 by xcaliber13
title correction
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...