Re: RegEx: text not inside

"Davide Brini [email protected] [sed-users]" <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
On Thu, 14 Aug 2014 23:01:57 +0200, "[email protected] [sed-users]"
<[email protected]> wrote:

> Hello,
> 
> I've read a difficult problem:
> a RegEx, that matches a string, which doesn't include a 2nd string.
> foo-xxx--bar -> no match
> foo-xyx--bar -> match
> It should match, if "foo.+?bar" doesn't contain "xx", something like
> "foo.+(?!xx)bar", but that matches always.

The best you can do in sed is to check that there is a match for (as an
example) foo-...-bar and if so, check that there is no match for whatever
you want to exclude. 
ISTR that some there are plans to add PCRE support to GNU sed, so at some
point you may be able to do it with a single regex in sed too.

But for the time being, use perl. Seriously.

-- 
D.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.