不要滥造正则表达式
对于常见的问题,其实早有人写好通用模式,做成漂亮的Regex::Common 模块放在CPAN上。
Regexp::Common::balanced Provides regexes for strings with balanced parenthesized delimiters. Regexp::Common::comment Provides regexes for comments of various languages (43 languages currently). Regexp::Common::delimited Provides regexes for delimited strings. Regexp::Common::lingua Provides regexes for palindromes. Regexp::Common::list Provides regexes for lists. Regexp::Common::net Provides regexes for IPv4 addresses and MAC addresses. Regexp::Common::number Provides regexes for numbers (integers and reals). Regexp::Common::profanity Provides regexes for profanity. Regexp::Common::whitespace Provides regexes for leading and trailing whitespace. Regexp::Common::zip Provides regexes for zip codes.