LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 10-28-2005, 09:08 AM   #1
gauge73
Member
 
Registered: Jan 2003
Location: Dallas, TX
Distribution: Fedora Core 4
Posts: 420

Rep: Reputation: 30
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?
 
Old 10-28-2005, 09:26 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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
 
Old 10-28-2005, 09:27 AM   #3
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
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.
 
Old 10-28-2005, 09:36 AM   #4
gauge73
Member
 
Registered: Jan 2003
Location: Dallas, TX
Distribution: Fedora Core 4
Posts: 420

Original Poster
Rep: Reputation: 30
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.
 
Old 10-28-2005, 09:48 AM   #5
gauge73
Member
 
Registered: Jan 2003
Location: Dallas, TX
Distribution: Fedora Core 4
Posts: 420

Original Poster
Rep: Reputation: 30
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?
 
Old 10-28-2005, 11:33 AM   #6
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular expression question gauge73 Linux - General 2 10-28-2005 09:32 AM
regular expression question zero79 Linux - Software 1 07-11-2005 07:03 PM
Regular expression question. groentebroer Programming 2 11-29-2004 09:15 PM
Regular expression question - John Sloan Linux - Software 1 09-08-2004 12:33 PM
regular expression question Gantrep Linux - Software 2 04-20-2003 04:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration