1 Reply Latest reply: Apr 19, 2007 9:45 AM by 807606 RSS

    negation of a phrase in regular expressions

    807606
      Hi,

      I'm building a regular expression, and can't seem find a way to negate a phrase.

      I need to find the following phrase
      *.png

      But to receive false for:
      */GeneratedImage/*.png

      I've tried using the following negation lookahead:
      String regexp = "/.*/(!?GeneratedImage)/.*\\.png";

      But the following line returnes true instead of false:
      pattern.matcher("/a/GeneratedImage/zxc.png").find());

      HELP! I'm dying here... :(

      Thanks,
      Rahav