Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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.
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.
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.
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?
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.