[Ruby] regex question

Aaron Patterson aaron_patterson at speakeasy.net
Mon Feb 12 11:19:34 PST 2007


On Mon, Feb 12, 2007 at 03:23:20AM -0800, shaners becker wrote:
> i have two questions about regexs:
> 
> 1. what's a good starting resource for learning regex? someone told  
> me about some ajaxy site that teaches the beginning in and outs of  
> regex. anyone know of that?

"Mastering Regular Expressions" is a pretty good book:

  http://www.oreilly.com/catalog/regex2/

I found it to be pretty dry, but now I can tell you the difference between
a DFA and an NFA regular expression engine.  It has good explainations
of greedyness, and how to deal with that stuff.  I found a sample
chapter:
  http://www.oreilly.com/catalog/regex/chapter/ch04.html

> 
> 2. just in textmate, i'm trying to do a find and replace that needs a  
> regex. its an xml file and i want to remove all of one type of tag  
> and its contents. say the tag is "book":
> 
> <book>moby dick</book>
> 
> how do i say find all: <book>...anything here...</book>?

blah =~ /<book>[^<]*<\/book>/

-- 
Aaron Patterson
http://tenderlovemaking.com/


More information about the Ruby mailing list