# Reg 0.4.8 Released

**URL:** <https://www.ruby-forum.com/t/reg-0-4-8-released/181030>\
**Category:** Ruby\
**Created:** [January 4, 2010, 8:37am UTC](https://www.ruby-forum.com/t/reg-0-4-8-released/181030 "2010-01-04T08:37:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pandemic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8491ac/32.png) [@pandemic](https://www.ruby-forum.com/u/pandemic)\
**Post date:** [January 4, 2010, 8:37am UTC](https://www.ruby-forum.com/t/reg-0-4-8-released/181030/1 "2010-01-04T08:37:33Z")

</div>

Reg version 0.4.8 has been released!

- [GitHub - coatl/reg: Reg is a library and language for pattern matching in ruby data structures. Reg provides Regexp-like match and match-and-replace for all data structures (particularly Arrays, Objects, and Hashes), not just Strings.](http://github.com/coatl/reg)

Reg is a library for pattern matching in ruby data structures. Reg  
provides  
Regexp-like match and match-and-replace for all data structures  
(particularly  
Arrays, Objects, and Hashes), not just Strings.

Reg is best thought of in analogy to regular expressions; Regexps are  
special  
data structures for matching Strings; Regs are special data structures  
for  
matching ANY type of ruby data (Strings included, using Regexps).

== Installation:

Type this command to install the gem:  
gem install reg  
Or, download the tarball from rubyforge:  
[http://rubyforge.org/frs/download.php/68391/reg-0.4.8.tar.gz](http://rubyforge.org/frs/download.php/68391/reg-0.4.8.tar.gz)

For more complete documentation, see:

> <https://github.com/coatl/reg/blob/master/article.txt>

== Examples:

“… the effect of drinking a Pan Galactic Gargle Blaster is like  
having  
your brains smashed out by a slice of lemon wrapped round a large gold  
brick.”  
– Douglas Adams, _Hitchhiker’s\_Guide\_to\_the\_Galaxy_

Reg is kind of hard to bend your brain around, so here are some  
examples:

Matches array containing exactly 2 elements; 1st is another array, 2nd  
is  
integer:  
+[Array,Integer]

Like above, but 1st is array of arrays of symbol  
+[+[+[Symbol+0]+0],Integer]

Matches array of at least 3 consecutive symbols and nothing else:  
+[Symbol+3]

Matches array with at least 3 symbols in it somewhere:  
+[OBS, Symbol+3, OBS]

Matches array of at most 6 strings starting with ‘g’  
+[/^g/-6] #no .reg necessary for regexp

Matches array of between 5 and 9 hashes containing a key :k pointing to  
something non-nil:  
+[+{:k=\>~nil.reg}\*(5…9)]

Matches an object with Integer instance variable @k and property (ie  
method)  
foobar that returns a string with ‘baz’ somewhere in it:  
-{:@k=\>Integer, :foobar=\>/baz/}

Matches array of 6 hashes with 6 as a value of every key, followed by  
18 objects with an attribute @s which is a String:  
+[+{OB=\>6}\*6, -{:@s=\>String}\*18]

Matches a single item whose method ‘length’ returns a Fixnum:  
item\_that.length.is\_a? Fixnum

Here’s an example of a Reg::Knows matcher, which matches objects that  
have the  
#slice method:  
-:slice

== Changes:

### 0.4.8 / 21dec2009

- 2 Major Bugfixes:
  - ported to ruby 1.9
  - dropped Cursor dependancy in favor of Sequence

- 2 Minor Bugfixes:
  - fixed empty array matcher matching non-empty arrays
  - actually handle the case of non-present rubygems.rb correctly
