Previous

Next


22. Metacharacters - Quantifiers: The Plus

  • The plus is unlike the question mark and the star in that it doesn't always necessarily succeed - because the plus requires at least one of the character being modified. As with the star, more than this minimum is fine.
  • So, if we wanted to find all the phone numbers that had just spaces separating the groups of numbers, but only the numbers that were separated (and not just a group of 8 numbers), then we could use the regex:
      [0-9]* +[0-9]*
            ^ Yes, there's a space in there :-)
            

Previous

Next

Andrew Hill

For LinuxSA Meeting, 21 November 2000