Question

Does anyone use have a good regex library that they like to use? Most of the regexes that you find online either contain bugs or are so focused on the edge cases that it turns into a competition to validate whatever spec 100%. Of course you can write your own, but when you are billing by the hour its handy to have a library around.

Was it helpful?

Solution

You can search for regular expression in regexlib.

OTHER TIPS

Boost, for c++

Besides being pretty much the best Regex tool on the market (seriously), RegexBuddy is about the only tool I know of that lets you switch amongst different Regex rendering engines.

http://www.regexbuddy.com/

See info here:

http://en.wikipedia.org/wiki/RegexBuddy

RegexBuddy's proprietary regular expression engine allows the software to emulate the rules and limitations of numerous popular regular expression flavors.

Lately, I do all my text parsing in Perl. If I needed regex's in another language, I'd go with PCRE.

The PCRE library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl 5. PCRE has its own native API, as well as a set of wrapper functions that correspond to the POSIX regular expression API. The PCRE library is free, even for building commercial software.

PCRE was originally written for the Exim MTA, but is now used by many high-profile open source projects, including Apache, PHP, KDE, Postfix, Analog, and Nmap. PCRE has also found its way into some well known commercial products, like Apple Safari. Some other interesting projects using PCRE include Chicken, Ferite, Onyx, Hypermail, Leafnode, Askemos, and Wenlin.

PCRE is mature, and has the support of numerous projects. Apache and Apple both have a vested interest in making it high-quality. I doubt that any other RE library is likely to surpass it in both functionality and quality (or possibly either) anytime soon.

One nice source that provides commonly requested regular expressions is Perl's Regexp::Common.

Currently provides patterns for the following (from the home page):

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.

e-texteditor hilights what you're searching for as you type it. This is incredibly useful, as you can paste your 'sample text' into a file, and just type your regex into the search field, and see what it's matching right in front of you.

None of these 'visual regex builder' things are substitutes for actually LEARNING regular expressions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top