Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular expression search, exclude a word [closed]

I like to search for a words containing string age in Visual Studio Find, I like to find age in CCAge or in any other string (like sage, mage, abcAGExyz) but not in message.

How can I achieve this?

like image 749
peter Avatar asked Feb 25 '13 03:02

peter


People also ask

How do you exclude words in regex?

To match any character except a list of excluded characters, put the excluded charaters between [^ and ] . The caret ^ must immediately follow the [ or else it stands for just itself.

What does \b mean in regex?

The \b metacharacter matches at the beginning or end of a word.

How do you search for a word in regex?

To run a “whole words only” search using a regular expression, simply place the word between two word boundaries, as we did with ‹ \bcat\b ›. The first ‹ \b › requires the ‹ c › to occur at the very start of the string, or after a nonword character.

How do you stop a character in regex?

Typing a caret after the opening square bracket negates the character class. The result is that the character class matches any character that is not in the character class.


1 Answers

This search regex should do the trick: ~(mess)age

~(X) is a Prevent match on X.

To ignore Tabpages as well, you can use ~(mess|tabp)age. Basically | is used as OR, like prevent match on mess OR tabp, you can add additional words via |.

like image 51
Petr Abdulin Avatar answered Oct 20 '22 04:10

Petr Abdulin