Previous

Next


24. Metacharacters - Quantifiers: Intervals

  • Be careful with intervals! Just like negation of a character class is matching a character that's not in the class, and not a magical "it doesn't matter if there's something there or not", so to is the following a little different to what we might expect:
      a{0, 0}
            
  • This means that the character "a" should match a minimum of zero times (or, if you like, there is no requirement to make a match), and that there should be a maximum of zero of them - in other words, don't even bother trying to make a match. The net result is that adding an interval like this has no effect on the rest of the regex!
  • It is not the same as saying that there must not be an "a" in this location.

Previous

Next

Andrew Hill

For LinuxSA Meeting, 21 November 2000