Todd1
(Todd)
1
Hello,
Sorry to waste your time with this, but I'm new to regular expressions.
I, simply want to grab the text between two html tags:
various characters and whitespace <span id="title">Dog Eggs</title>
various characters and whitespace
I want a regex that notices the "title" id and grabs Dog Eggs for me.
I have one that works, but it's really kludgey.
Thanks,
Todd
W_James
(W. James)
2
Todd wrote:
Hello,
Sorry to waste your time with this, but I'm new to regular expressions.
I, simply want to grab the text between two html tags:
various characters and whitespace <span id="title">Dog Eggs</title>
various characters and whitespace
I want a regex that notices the "title" id and grabs Dog Eggs for me.
I have one that works, but it's really kludgey.
Thanks,
Todd
DATA.read.scan( /id="title">(.*?)</m ) { |s|
puts s
}
__END__
characters and whitespace <span id="title">Platypus Eggs</title>
various characters and whitespace
<span id="title">Bird
Teeth</title>
Hello,
Sorry to waste your time with this, but I'm new to regular expressions.
I, simply want to grab the text between two html tags:
various characters and whitespace <span id="title">Dog Eggs</title>
various characters and whitespace
I want a regex that notices the "title" id and grabs Dog Eggs for me.
I have one that works, but it's really kludgey.
Thanks,
Todd
irb(main):001:0> text = %(<span id="title">Dog Eggs</title>)
=> "<span id=\"title\">Dog Eggs</title>"
irb(main):002:0> text[%r(<span id="title">(.*?)</title>), 1]
=> "Dog Eggs"
I really like this interface.
regards,
Brian
···
On 25/10/05, Todd <toddkennethbenson@yahoo.com> wrote:
--
http://ruby.brian-schroeder.de/
Stringed instrument chords: http://chordlist.brian-schroeder.de/
Todd1
(Todd)
4
Perfect, thanks! Didn't know about String.scan.
Todd