Hi there,
Please can someone help me with this query.
I’m writing a script to perform a GREP search on some copy using TextWrangler.
The regular expression is working ok and finds the relevant text however what I’d like to do is store
part of the value returned in a variable. This is where I’ve come a little unstuck.
Here’s the regular expression:- (@AG Medium Drop Cap:)([A-Z]*)
As you can see there are two parts to it, it’s the value returned by the second part I want to store in a variable.
If I do a GREP find and replace and put ‘\2’ as the replacement value I can see the right value is being returned.
I’ve had a look at the dictionary and the sample scripts. One of which (shown below) gave me a start but as yet
I’ve not found the right way to get the 2nd ‘subpattern’ value into a variable.
Here’s the script:-
tell application "TextWrangler"
set matchOptions to {match mode:leaving_one, match pattern:"^.*\\t(<.*>)", match subpattern:"\\1", match subpattern key:use_subpattern}
set outputOptions to {deleting duplicates:true}
process duplicate lines (text 1 of window 1) ¬
duplicates options matchOptions ¬
output options outputOptions
end tell
Please can someone point me in the right direction.
Thanks in advance,
Regards,
Nick