On 5 Oct. 2016, at 10:54 am, Brian Christmas <
There is, but trust me, you really don't want to go there.
As you're already using AppleScriptObjC, why not try that? You could use regular expressions to find the relevant paragraphs, something like this:
-- change encoding to match file
set theString to current application's NSString's stringWithContentsOfFile:(POSIX path of eachFile) encoding:(current application's NSUTF8StringEncoding) |error|:(missing value)
-- make sure match string is regex "safe"
set thePattern to (current application's NSRegularExpression's escapedPatternForString:"abc") as text
-- put a unique character at start of matching lines
set theString to theString's stringByReplacingOccurrencesOfString:(".*" & thePattern & ".*") withString:"π$0" options:(current application's NSRegularExpressionSearch) range:{0, theString's |length|()}
-- delete all lines that don't start with the unique character
set theString to theString's stringByReplacingOccurrencesOfString:"(?m)^[^π].*(\\n|\\r)*" withString:"" options:(current application's NSRegularExpressionSearch) range:{0, theString's |length|()}
-- delete the unique character at the beginning of lines
set theString to theString's stringByReplacingOccurrencesOfString:"(?m)^π" withString:"" options:(current application's NSRegularExpressionSearch) range:{0, theString's |length|()}
-- strip trailing returns/linefeeds
set theString to theString's stringByTrimmingCharactersInSet:(current application's NSCharacterSet's whitespaceAndNewlineCharacterSet())
-- convert to paras of AS text
set theParas to paragraphs of (theString as text)
And what, you ask, was the beginning of it all?
And it is this......
Existence that multiplied itself
For sheer delight of being
And plunged with numberless trillions of forms
So that it might
find
itself
innumerably
Sri Aurobindo