LinuxQuestions.org
Help answer threads with 0 replies.
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, 10: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, 10:26 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
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, 10:27 AM   #3
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,028
Blog Entries: 5

Rep: Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791
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, 10: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, 10: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, 12:33 PM   #6
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,028
Blog Entries: 5

Rep: Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 10:32 AM
regular expression question zero79 Linux - Software 1 07-11-2005 08:03 PM
Regular expression question. groentebroer Programming 2 11-29-2004 10:15 PM
Regular expression question - John Sloan Linux - Software 1 09-08-2004 01:33 PM
regular expression question Gantrep Linux - Software 2 04-20-2003 05:24 PM


All times are GMT -5. The time now is 12:31 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration