cnuregexp
====================

-What is cnuregexp?
cnuregexp allows tags to be placed inside a regex which function as labels
for the matches. The matches within the MatchData object can
then be accessed like a hash with the tag name as the key. cnuregexp also
provides a greedy match which will return an array of all matches rather than
just the first match.

cnuregexp can also extract various data from an xml tag with the Regexp.xml_tag
method. It uses Regexps to get the tag name, the attributes and their values,
the tag content, and any other relevant data from an xml string.

Lastly, cnuregexp allows commonly used regular expressions to be stored in a
config file(lib/cnuregexp_config.yml) and accessed with
Regexp.regular_expression_name notation eg. Regexp.ssn, Regexp.email_address.
cnuregexp comes preloaded with a few common regular expressions which are
located in lib/cnuregexp_config.yml.

-Installation
sudo gem install cnuregexp

-Examples
re=/((?# areacode)[0-9]3)-((?# number)[0-9]3-[0-9]4)/.tag!
m=re.match("my phone number is 312-243-0979")
m["areacode"] # => "312"
m["number"] # => ["243-0979"]

r = Regexp.xml_tag :a, :attr2=>true, :attr_not_exist=>false
m = r.match('<a href="#test" attr2="_test">test</a>')
m[:href_value] # => "#test"
m[:attr2_value] # => "_test"
m[:content] # => "test"

Regexp.email_address # => / \b ((?# user) (?!\.+)(?!-+)[\w\d._%\-+]+ ) @ ((?# subdomain) ((?!-+)[\w\d\-]+\.)* ((?!-+)[\w\d\-]+ ) ) \. ((?# tld) \w2,6 ) \b /x

-License
cnuregexp is distributed under the Ruby license

-Contact
website: www.opensource.cashnetusa.com, www.usergenic.com
email: [email protected], [email protected]