match any character but

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jon Slaughter

    match any character but

    Can I use any reg exp(mainly for mod rewrite) where I can match any
    character but a fixed list?

    I need to match a string that does not contain any /'s but I don't want to
    have to use a character search string. (I don't see any need to have to
    hardcode it)

    that is,

    ..

    matches any single charactr

    and (.*) matches any string

    what I want to do is use something like % that means

    ..%/

    which means match any character but /.

    Of course it would need to be valid and I know I can't make up semantics for
    the reg ex. My point is is that, is that I don't want to have to use
    [a-z0-9\-%&^$#@!etc...] to mean . but not /.

    Surely there is a way to exclude a few characters from . without having to
    increase the complexity of the expression 1000 fold?

    If you don't get that, then a simple example would be that I have an
    arbitrary string and I want to match only if that string does not contain an
    a. Sure I can so something like
    [bcdefghijklmnop qrstuv123456789 0!@#$%^&*()_+][';/.,<>?:"{}+-=~`............ ..............]
    but surely reg exp has an easier way??? (again, this is specifically for mod
    rewrite)


    Thanks,
    Jon


  • Michael Fesser

    #2
    Re: match any character but

    ..oO(Jon Slaughter)
    >Can I use any reg exp(mainly for mod rewrite) where I can match any
    >character but a fixed list?
    Use a character class with a leading ^ to negate it:

    [^/]

    Matches anything that is not a slash.

    Micha

    Comment

    • Jon Slaughter

      #3
      Re: match any character but


      "Michael Fesser" <netizen@gmx.de wrote in message
      news:9bko33pahg 36eddgsc8pmoodd 6qeis75sn@4ax.c om...
      .oO(Jon Slaughter)
      >
      >>Can I use any reg exp(mainly for mod rewrite) where I can match any
      >>character but a fixed list?
      >
      Use a character class with a leading ^ to negate it:
      >
      [^/]
      >
      Matches anything that is not a slash.
      >
      Ok. Duh. wasn't putting 2 and 2 together. [^/] should match anything but a
      slash. lol.

      Thanks,
      Jon


      Comment

      Working...