[Ruby] regex question
Daevid Vincent
daevid at daevid.com
Mon Feb 12 12:42:05 PST 2007
I've always liked "Regex Coach"
http://weitz.de/regex-coach/
http://weitz.de/regex-coach/#older
DÆVID
> -----Original Message-----
> From: ruby-bounces at zenspider.com
> [mailto:ruby-bounces at zenspider.com] On Behalf Of Andrew Nutter-Upham
> Sent: Monday, February 12, 2007 11:05 AM
> To: Seattle Ruby Brigade!
> Subject: Re: [Ruby] regex question
>
> I find visual feedback helpful when learning or working with
> complex regexes
> try:
> http://laurent.riesterer.free.fr/regexp/
>
>
> On 2/12/07, Mike Mondragon <mikemondragon at gmail.com> wrote:
> >
> > On 2/12/07, shaners becker <veganstraightedge at gmail.com> 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?
> > >
> > > 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>?
> > >
> > > thanks
> > > shaners
> > >
> > >
> > > -----------
> > > join the resistance. fall in love.
> > > http://theresistancearmy.com/
> >
> > I just practice a regexp in irb to make sure it works correctly.
> >
> > Sounds like you need a global substitution in place. Try
> this out in
> > irb .* is greedy and assumes that there is only one <book>foo</book>
> > per line. Also gsub! modifies the receiver, gsub returns a new
> > string.
> >
> > b="<book>moby dick</book>\nhello\n<book>another book</book>"
> > b.gsub(/<book>.*<\/book>/, "")
> > b.gsub!(/<book>.*<\/book>/, "")
> >
> > --
> > Mike Mondragon
> > http://mondragon.cc/
> > _______________________________________________
> > Ruby at zenspider.com - Seattle.rb non-commercial list
> > http://www.zenspider.com/seattle.rb
> > http://www.zenspider.com/mailman/listinfo/ruby
> >
>
>
>
> --
> Andy
> _______________________________________________
> Ruby at zenspider.com - Seattle.rb non-commercial list
> http://www.zenspider.com/seattle.rb
> http://www.zenspider.com/mailman/listinfo/ruby
>
More information about the Ruby
mailing list