Software Design
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreSoftware Design

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 6th, 2003, 06:40 PM
douceur douceur is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 4 douceur User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Regexp Difficulties

Hi. I want to match a string with a regexp patter similar to:

'/X(not foo|bar)X/'

Basically, it would match anything except 'XfooX' and 'XbarX'.

The closest pattern I can come up with is '/X[^(foo|bar)]X/'.

This, however, doesn't work because ()'s lose their "special powers" within []'s. Is there any simple way to do this? And if there's no simple way, what would be the complex way?

EDIT: Wait a minute... I guess I actually posted incorrectly. Sorry about that... I would want it to match strings such as 'XasdfX' and 'XffffffffffffffffX' and 'XzxbcvasdfaX'. I just don't want it to match the string if it has 'foo' or 'bar' in the middle of the X's. In fact, I would also like it to match 'foo XasdfX bar'.

Last edited by douceur : May 6th, 2003 at 06:54 PM.

Reply With Quote
  #2  
Old May 8th, 2003, 02:30 PM
manoloweb's Avatar
manoloweb manoloweb is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Location: Mexico
Posts: 116 manoloweb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 17 sec
Reputation Power: 11
How about making 2 different checks?

IF

Match 'X(foo|bar)X'

OUT

ELSEIF

Match 'X([a-zA-Z])X'

IN

ELSE

OUT
__________________
The best way to learn is:
read + try + ask (in that order)

Manolo

Reply With Quote
  #3  
Old May 8th, 2003, 03:08 PM
douceur douceur is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 4 douceur User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for the help, though I believe that my problem has been solved by somebody on a different message board:

/X(?!fooX|barX)X/

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreSoftware Design > Regexp Difficulties

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap