On Mar 02, 2015, at 21:32, Jared Roller <simonat...@gmail.com> wrote:
> Yep, I think the most intuitive route for me would be for the replacement 
> patterns to work with the new Extract button in 'Find and Replace'.
______________________________________________________________________

Hey Jared,

I think your idea merits a feature request.  If you have not done so already 
please send one to Bare Bones Software <supp...@barebones.com>.

And make your case.  Don't just write up the request - tell/show them WHY it 
would add value to BBEdit.

Keep in mind though that much is possible once you learn a bit about 
AppleScript and shell scripting.

-------------------------------------------------------------------------------------------
#! /usr/bin/env bash

osascript -s o -e 'tell application "BBEdit" to return text of front text 
window' | tr '\r' '\n' \
| perl -wlne 'if ( m!(http://\S+).*(by Shane.+)!ims ) { print "$1\t$2" }';
-------------------------------------------------------------------------------------------

This extracts the text from the front document and prints (to a window) a 
report of the items found by the perl regex using only the specific captures.

This particular code only operates on a per-line basis, but it is possible to 
match multiple line patterns.

When it comes to extracting text I generally prefer to use the Satimage.osax 
(AppleScript Extension), because it's easier to manage complex multiple line 
patterns.

A very simple example:

-------------------------------------------------------------------------------------------
tell application "BBEdit"
  tell text of front text window to set _text to it
end tell
set foundText to find text "(?im)(^detect.+^detect[^\\r]+)" in _text using 
"\\1" with regexp, all occurrences and string result
tell application "BBEdit"
  make new document with properties {name:"Text Extraction - Unsaved", 
text:foundText}
end tell
-------------------------------------------------------------------------------------------

Much of this can also be done with BBEdit's own AppleScript dictionary.

So what you want to do can be done NOW without a whole lot of learning on your 
part.

It's not as simple as pushing the {Extract} button, but it's pretty easy - 
especially if you keep a boilerplate script handy.

--
Best Regards,
Chris

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.

Reply via email to