[Ruby] regex question
Eric Hodel
drbrain at segment7.net
Mon Feb 12 11:23:49 PST 2007
On Feb 12, 2007, at 11:19, Aaron Patterson wrote:
> On Mon, Feb 12, 2007 at 03:23:20AM -0800, shaners becker wrote:
>> 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>/
Also, a question mark turns a greedy match into a non-greedy match:
blah =~ /<book>.*?<\/book>/
More information about the Ruby
mailing list