Personal computing discussed

Moderators: SecretSquirrel, just brew it!

 
gratuitous
Gerbil Team Leader
Topic Author
Posts: 231
Joined: Fri Jan 28, 2005 3:05 pm

Excluding a Whole Word with Regular Expression

Sat Oct 22, 2005 1:36 am

Last edited by gratuitous on Thu Dec 15, 2005 1:09 pm, edited 2 times in total.
 
Usacomp2k3
Gerbil God
Posts: 21495
Joined: Thu Apr 01, 2004 4:53 pm
Location: Orlando, FL
Contact:

Sat Oct 22, 2005 1:44 am

Do you mean like a google search? Then it would just be "-fox" however, that's too easy, so I guess I don't understand the question.
 
gratuitous
Gerbil Team Leader
Topic Author
Posts: 231
Joined: Fri Jan 28, 2005 3:05 pm

Sat Oct 22, 2005 1:47 am

Last edited by gratuitous on Thu Dec 15, 2005 1:09 pm, edited 1 time in total.
 
Usacomp2k3
Gerbil God
Posts: 21495
Joined: Thu Apr 01, 2004 4:53 pm
Location: Orlando, FL
Contact:

Sat Oct 22, 2005 1:51 am

:o Quite a bit over my head then. Good luck 8)
 
notfred
Maximum Gerbil
Posts: 4227
Joined: Tue Aug 10, 2004 10:10 am
Location: Ottawa, Canada

Sat Oct 22, 2005 11:54 am

Probably do better in Developer's Den.

If you can call out to grep then do it as a "grep -v" that's probably the easiest way.
 
morphine
Silver subscriber
Gerbilus Supremus
Posts: 11187
Joined: Fri Dec 27, 2002 8:51 pm
Location: Portugal (that's next to Spain)

Sat Oct 22, 2005 12:11 pm

(.*?)dog(.*)

This you capture everything before "dog" and after "dog", essentialy giving you the same result. I presume you're using this inside some sort of program for text search/matching.
 
gratuitous
Gerbil Team Leader
Topic Author
Posts: 231
Joined: Fri Jan 28, 2005 3:05 pm

Sat Oct 22, 2005 5:25 pm

Last edited by gratuitous on Thu Dec 15, 2005 1:10 pm, edited 1 time in total.
 
morphine
Silver subscriber
Gerbilus Supremus
Posts: 11187
Joined: Fri Dec 27, 2002 8:51 pm
Location: Portugal (that's next to Spain)

Sat Oct 22, 2005 5:55 pm

The given regular expression was meant to be used in some sort of program (it's a Perl-compatible regular expression, although this particular case is not Perl-specific).

If you're looking for a usenet post in some page, then I'm betting that page has some sort of specific form of regexp query, which is useless for us trying to guess what it is :)

What's the specific site?
 
gratuitous
Gerbil Team Leader
Topic Author
Posts: 231
Joined: Fri Jan 28, 2005 3:05 pm

Sat Oct 22, 2005 6:20 pm

Last edited by gratuitous on Thu Dec 15, 2005 1:11 pm, edited 1 time in total.
 
morphine
Silver subscriber
Gerbilus Supremus
Posts: 11187
Joined: Fri Dec 27, 2002 8:51 pm
Location: Portugal (that's next to Spain)

Mon Oct 24, 2005 12:46 pm

Someone named Jeff on ICQ left this to me, so I thought I'd share it with you (maybe Jeff is the poster, I don't know :) )

In answer to this thread that
you posted in:

viewtopic.php?t=34782

Here is the regex that solves the problem:

http://www.codinghorror.com/blog/archives/000425.html

Could you post it in the thread?

Thanks,

Jeff
 
thegleek
Gold subscriber
Darth Gerbil
Posts: 7406
Joined: Tue Jun 10, 2003 11:06 am
Location: Detroit, MI
Contact:

Mon Oct 24, 2005 2:44 pm

cat filename.ext | grep -v yourwordgoeshere
Image
 
gratuitous
Gerbil Team Leader
Topic Author
Posts: 231
Joined: Fri Jan 28, 2005 3:05 pm

Mon Oct 24, 2005 4:44 pm

Last edited by gratuitous on Thu Dec 15, 2005 1:11 pm, edited 1 time in total.
 
JavaDog
Minister of Gerbil Affairs
Posts: 2798
Joined: Wed May 07, 2003 11:20 am
Location: Oahu, HI

Mon Oct 24, 2005 5:50 pm

Just code your own usenet reader...
 
Captain Ned
Gold subscriber
Global Moderator
Posts: 24422
Joined: Wed Jan 16, 2002 7:00 pm
Location: Vermont, USA

Mon Oct 24, 2005 5:55 pm

Hmm, this is really looking like code jockey stuff, so off to The Developer's Den it goes.
Never ask a woman who is eating ice cream straight from the carton how she's doing.
 
morphine
Silver subscriber
Gerbilus Supremus
Posts: 11187
Joined: Fri Dec 27, 2002 8:51 pm
Location: Portugal (that's next to Spain)

Mon Oct 24, 2005 6:59 pm

Well, that's life :)

But yeah, you should use your own usenet reader instead of a third-party solution.
 
gratuitous
Gerbil Team Leader
Topic Author
Posts: 231
Joined: Fri Jan 28, 2005 3:05 pm

Mon Oct 24, 2005 7:09 pm

Last edited by gratuitous on Thu Dec 15, 2005 1:12 pm, edited 1 time in total.
 
SecretSquirrel
Minister of Gerbil Affairs
Posts: 2187
Joined: Tue Jan 01, 2002 7:00 pm
Location: The Colony, TX (Dallas suburb)
Contact:

Mon Oct 24, 2005 8:28 pm

The perlish regexp would be:

$string="The quick brown fox jumped over the lazy dog.";
$search="fox"
$string=~s/\s$search(\s)/$1/g;


If will search for the search term surrounded by a whitespace character and strip it out. The parens around the second whitespace save it and it is actually used as the replacement source. This keeps you from getting "brownjumped" by removing both whitespace elements. You should actually extend it to take into account it being the first in the sentance or being followed by punctuation or stuff.

--SS
 
jimveta
Gerbil In Training
Posts: 3
Joined: Fri Jan 28, 2005 6:05 pm
Location: Los Angeles, CA

Thu Nov 17, 2005 2:41 am

the standard way of specifying a "word" regex is
\<fox\>

(it will match "fox" surrounded by spaces, punctuation, etc)
.. now all you need is a way to negate that which unfortunately isn't so standardized.. does the webform page you're using this in have a manual?

Who is online

Users browsing this forum: No registered users and 0 guests