You can't assume you're searching for Address Book.app. If you don't know what can be before the .app, the search has to be a little more clever.
On Jan 19, 2:10 am, Marek Stepanek <ms...@podiuminternational.org> wrote: > On 18.01.2011 22:02, Ronald J Kimball wrote: > > > > > On Tue, Jan 18, 2011 at 01:29:50PM -0600, Christopher Stone wrote: > >> Hey Folks, > > >> I've been looking at positive and negative assertions until my head is > >> spinning. :) > > >> What I want to do is find the entirety of line 1 but *not* line 2: > > >> ./Address Book.app > >> ./Address Book.app/Contents/CodeResources.app > > >> So I want to find a line that ends with ".app" but it cannot contain > >> ".app" except at the end. > > > Here's the approach I usually take for this kind of task: > > > ^(?>(?:(?!\.app).)*)\.app$ > > > (?:(?!\.app).)* matches a substring that doesn't contain ".app". It does > > this by checking whether the next part of the string is ".app"; if it's > > not, it matches one character, and repeats. > > > (?>...) prevents the regex from backtracking into its subexpression once it > > matches. We know that if the regex doesn't get to the end of the string, > > backtracking isn't going to help. > > > But I also thought of a simpler approach in this case: > > > ^(?!.*\.app.*\.app).*\.app$ > > > That one uses a negative lookahead to make sure the string doesn't contain > > .app twice, and then matches if it contains .app at the end of the string. > > > Ronald > > Hello all! > > Did I oversaw something? This looks little bit like an overkill. Would > it not be sufficient, to search for an and of line with grep: > > \./Address Book\.app$ > > Or if it is not at the end of line, probable with a word boundary: > > \./Address Book\.app\b > > Best greetings from Munich > > marek -- 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>