RegEx for searching all but a given token ?

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
sergeant
Posts: 7
Joined: Thu Sep 18, 2003 9:42 pm

RegEx for searching all but a given token ?

Post by sergeant »

Hello,

how I can search (using regular expressions) for lines, which do
not contain a given token.

For example, maybe I have several variables beginning int_var1.., int_var2.., ...Now I want to search all lines of the C-source, which do not contain int, something like [^(int)]_var.

Thanks for any hint!

Regards

Juergen
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

I think the easiest method is to Mark All with int_var and then toggle the Marked Lines.
Try this for your hint:


1. Search, Find, Mark All for the following:
^int_var

2. Close Find Window

3. Search, Invert All Bookmarks

Works with/without POSIX format

Hope this is helpful.................good luck,
Bob
User avatar
s_reynisson
Posts: 939
Joined: Tue May 06, 2003 1:59 pm

Post by s_reynisson »

Std answer is here. Also, I googled around a bit and found this and the main result there is
the same:
To see why it is impossible to constuct a regex that matches
anything but another regex you have to look at how regexs work in
terms of DFAs and all that - and then think on it for a few
hours
Using TP you can find all lines containing your string, bookmark those lines and then invert them.

dogh! Bob beat me to it... :oops:
Post Reply