in reply to specific numbers of digits

emichswimr,
If you know that your input string will only be a sequence of digits, then use pg's solution of anchoring with ^ and $. If you need to match within a string, then one of these may help.

/\b\d{5}\b/; or /\D\d{5}\D/; or /\s+\d{5}\s+/;
  • The first one breaks on word boundaries (any character not in \w)
  • The second one breaks on any non digit
  • The third one breaks on white spaces

    Cheers - L~R

    Update: Changed introduction to explain why these solutions may be more flexible then the ones that anchor with ^ and $