Wow, Chris, thanks so much! Both work great. Totally going to pick these 
apart and learn something. Appreciate it!

- eric

On Sunday, August 15, 2021 at 7:30:43 AM UTC-7 [email protected] wrote:

> On Aug 13, 2021, at 21:30, e2o <[email protected]> wrote:
>
>
> Howdy! Is there an easy way to copy a chunk of text matched with a regular 
> expression to the clipboard only? No search/replace.
>
> I have an expression that selects everything at the beginning of a 
> document up to but not including the first blank line. I need to copy this 
> text and copy it to the bottom of the document. I can't use Process Lines 
> Including because it uses \A to match beginning of document, which doesn't 
> fly there.
>
> So my expression is:
>
> \A.*\r(^\S.*\r)+
>
> ------------------------------
>
> Hey Eric,
>
> Your pattern does not fully match your verbal description.  Whenever 
> asking for text processing help please *always* include *at least* one 
> good *real-world* before and after example.
>
> Doing so will *always* save yourself and anyone who helps you both time 
> and aggravation.
>
> From what I understand your task is really just a simple find/replace.
>
> AppleScriptified:
>
>
> -------------------------------------------------------------------------------------------
> # Auth: Christopher Stone
> # dCre: 2021/08/15 09:01
> # dMod: 2021/08/15 09:01 
> # Appl: BBEdit
> # Task: Copy text from (the beginnging of a document to the first blank 
> line) to the end of document.
> # Libs: None
> # Osax: None
> # Tags: @Applescript, @Script, @BBEdit, @RegEx
> # Note: Posted to BBEdit-Talk for <[email protected]>.
>
> -------------------------------------------------------------------------------------------
>
> *tell* *application* "BBEdit"
>     *tell* *front* *text document's* *text*
>         *replace* "(?ms)(\\A.*?)(?=^$)(.+)" using "\\1\\2\\n-----\\n\\1" 
> options {search mode:*grep*, case sensitive:*false*, starting at top:
> *true*}
>     *end* *tell*
> *end* *tell*
>
>
> -------------------------------------------------------------------------------------------
>
> Using a Text Factory would be the simplest method, but as you can see the 
> AppleScripted version isn't particularly difficult.
>
> I've added a separator for a visual cue, which you can change as you like.
>
> Now then – let's tackle the task as you describe it via AppleScript but 
> without using the clipboard, since copy and paste is completely unnecessary.
>
> Knowing how to do this may come in handy some time.
>
>
> -------------------------------------------------------------------------------------------
> # Auth: Christopher Stone
> # dCre: 2021/08/15 09:01
> # dMod: 2021/08/15 09:19
> # Appl: BBEdit
> # Task: Copy text from (the beginnging of a document to the first blank 
> line) to the end of document.
> # Libs: None
> # Osax: None
> # Tags: @Applescript, @Script, @BBEdit, @RegEx
> # Note: Posted to BBEdit-Talk for <[email protected]>.
>
> -------------------------------------------------------------------------------------------
> *property* LF : linefeed
>
> -------------------------------------------------------------------------------------------
>
> *tell* *application* "BBEdit"
>
>     
>     *tell* *front* *text document's* *text*
>
>         
>         *set* findRecord *to* *find* "(?ms)(\\A.*?)(?=^$)" options ¬
>             {search mode:*grep*, case sensitive:*false*, starting at top:
> *true*}
>
>         
>         *if* found *of* findRecord *is* *true* *then*
>             *set* *after* *it* *to* LF & LF & findRecord's found text
>         *end* *if*
>
>         
>     *end* *tell*
>
>     
> *end* *tell*
>
>
> -------------------------------------------------------------------------------------------
>
> Doing it this way isn't particularly difficult either, even if it's a 
> little less straightforward.
>
> --
> Best Regards,
> Chris
>
>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/f39af088-19ef-4a60-9503-f52751305754n%40googlegroups.com.

Reply via email to