On Mar 12, 2017, at 15:39, Rob Lewis <[email protected]
<mailto:[email protected]>> wrote:
> It would also be useful to have an inverse operation to process lines that do
> not contain the search string.
Hey Rob,
If you know enough about regular expression then it's doable:
^(?>(?:(?!Your_Pattern_Here).)+)$
This won't manage blank lines from the “Process Lines Containing” dialog though.
> I know that grep's -v option does this, but it doesn't seem to work here.
That's because -v is a command-line-switch for the `grep` command-line-tool –
it's not a syntactical meta-character for BBEdit's regex library.
This task can be accomplished quite easily using BBEdit's Text-Filter feature.
This filter will delete any lines NOT containing the pattern:
#!/usr/bin/env bash
sed -E '/Your_Pattern_Here/!d'
This filter will print only lines NOT containing the pattern:
#!/usr/bin/env bash
sed -En '/Your_Pattern_Here/!p'
If you want a little bit of UI and can deal with a literal-string then you can
roll-your-own:
-------------------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2017/03/12 19:15
# dMod: 2017/03/12 19:24
# Appl: BBEdit
# Task: Present the user a dailog to enter a string – return lines NOT
containing the string in a new document.
# : Remove blank lines.
# : Not well suited for *really* big documents.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Dailog, @Enter, @String, @Return,
@Lines, @NOT, @Containing, @New, @Document
-------------------------------------------------------------------------------------------
tell application "BBEdit"
set ddTextReturned to text returned of (display dialog "Enter your text:"
default answer "" with title "•• Find Lines NOT Containing ••" giving up after
30)
tell front text document
set myLines to contents of lines whose contents does not contain
ddTextReturned and contents is not ""
end tell
if length of myLines > 0 then
set AppleScript's text item delimiters to linefeed
set newDoc to make new document with properties {text:myLines as text}
end if
end tell
-------------------------------------------------------------------------------------------
Run it from the Script Editor.app to see how it works.
--
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
"[email protected]" 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/bbedit.