On 13/02/2013 02:32, Jim Harvey wrote:

  I do some grep searching once in a while, but this one has me stumped. I have 
some large text files, and I need to find the nth occurrence of a string (or 
pattern).

Here's an AppleScript script that finds the 4th occurrence of "do" in the front document. I expect someone can give you a less clumsy way to do it.

set _regex to "do"
set _n to 4
set _i to 0
set _max to 1000 -- max possible occurrences
tell application "BBEdit" to tell the front document
    activate
    select insertion point before character 1
    repeat _max times
        set _i to _i + 1
        find _regex ¬
            options ¬
            {search mode:grep} ¬
                searching in its text ¬
            with selecting match
        if _i ≥ _n then
            exit repeat
        end if
    end repeat
end tell

--JD

--
--
You received this message because you are subscribed to the "BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
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.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to