[thelist] RegExp - how to say "not this string"

Carl Meyer cjmeyer at npcc.net
Tue May 11 10:39:10 CDT 2004


hi Sarah,

On Tue, 11 May 2004, Sarah Sweeney wrote:
> I know that ^x means not x - is there a way to specify "not this 
> string"? Basically, what I want is something more like this:
> <th>(^(</th>))</th>

This doesn't answer your question directly, but for the situation you
describe I would simply use this regex:

<th>(.*?)</th>

The ? makes the wildcard "non-greedy" - it matches as little as possible
rather than as much as possible - so </th> will match the first </th> it
finds.  This should eliminate the need for the "not this string" match,
unless I misunderstand your situation.

I can't speak for Homesite's regex engine, but this syntax works in Perl and
Emacs, the two environments where I use regexes.

hth,

Carl



More information about the thelist mailing list