dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: Regexp Difficulties

  1. #1
    Join Date
    May 2003
    Posts
    2

    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?

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,279
    !/X(foo|bar)X/
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  3. #3
    Join Date
    May 2003
    Posts
    2
    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'.

  4. #4
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,279
    /X[a-z]+X/ && !/X(foo|bar)X/
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles