LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Regular expression question (http://www.linuxquestions.org/questions/linux-general-1/regular-expression-question-377727/)

gauge73 10-28-2005 10:08 AM

Regular expression question
 
I've been trying desparately to figure out how to write a regular expression that will match any string except a particular URL. I can't, however, figure out how to do an inverse of an expression. Can anyone tell me how I might do this? I've tried the following (example for www.google.com):

http:\/\/...\.[^g][^o][^o][^g][^l][^e]

But it has weaknesses including the fact that any domain name starting with a "g" will not match. Can you guys point me in the right direction?

acid_kewpie 10-28-2005 10:26 AM

Please do not post the same thread in more than one forum. Picking the most relevant forum and posting it once there makes it easier for other members to help you and keeps the discussion all in one place.

http://www.linuxquestions.org/rules.php

MensaWater 10-28-2005 10:27 AM

What utility are you using. Regular expressions often are modified within utilities.

For example "grep -v <pattern>" would say get everything EXCEPT <pattern>.

In other utilities using the exclamation point ("!" a/k/a bang) means "not" so putting it at the beginning of the pattern may work. For example doing "ls !(*.sh) would say to list all files EXCEPT the ones ending in .sh.

Doing "man <utility>" on whichever utility you're using may give you special usage for regular expression (see "man sed" for example) for that utility.

gauge73 10-28-2005 10:36 AM

Quote:

Originally posted by acid_kewpie
Please do not post the same thread in more than one forum. Picking the most relevant forum and posting it once there makes it easier for other members to help you and keeps the discussion all in one place.

http://www.linuxquestions.org/rules.php

This was a mistake. I'm sorry about the inconvenience. I'm pretty sure I didn't hit submit more than once. Feel free to delete the other thread as it has no related resposnes.

gauge73 10-28-2005 10:48 AM

Quote:

Originally posted by jlightner
What utility are you using. Regular expressions often are modified within utilities.

For example "grep -v <pattern>" would say get everything EXCEPT <pattern>.

In other utilities using the exclamation point ("!" a/k/a bang) means "not" so putting it at the beginning of the pattern may work. For example doing "ls !(*.sh) would say to list all files EXCEPT the ones ending in .sh.

Doing "man <utility>" on whichever utility you're using may give you special usage for regular expression (see "man sed" for example) for that utility.

This is a Linux-based appliance. All I am doing is entering the expression into a GUI. I would assume that something like grep, awk, or sed is being used in the background. I've tried a !, but it seems to be invalid. Is there any other way to invert an expression so that anything BUT the expression matches?

MensaWater 10-28-2005 12:33 PM

As I noted before it really depends on the utility being used. You'd have to find documentation for the application's GUI that you're running to find out what it expects. It may be (in fact is likely) that it is the application that is rejecting what it thinks are unexpected characters.


All times are GMT -5. The time now is 09:05 PM.