Hi experts,
I’m not very familiar with ruby’s library. I wonder if there a method
can extract something in a pattern? For example,
I have a string: a=aabbcc
ccddee
I wanna get the anything between
and
, which is ccddeeThanks in advance.
Hi experts,
I’m not very familiar with ruby’s library. I wonder if there a method
can extract something in a pattern? For example,
I have a string: a=aabbcc
ccddee
I wanna get the anything between
and
, which is ccddeeThanks in advance.
Cheyne Li wrote:
Hi experts,
I’m not very familiar with ruby’s library. I wonder if there a method
can extract something in a pattern? For example,I have a string: a=aabbcc
ccddee
I wanna get the anything between
and
, which is ccddeeThanks in advance.
C:\Users\Alex>irb
irb(main):001:0> require ‘hpricot’
=> true
irb(main):002:0> a=“aabbcc
ccddee
”ccddee
”“ccddee”
}>Li
Ya, in this case (HTML/XML), Hpricot is your best bet.
Otherwise, standard regex stuff would apply, imo.
On Sep 22, 12:58 pm, Cheyne Li [email protected] wrote:
–
Posted viahttp://www.ruby-forum.com/.
If you want to use regexp, a quick and dirty way would be :
(a.split %r{</?p>})[1]
[email protected] wrote:
Thanks in advance.
Posted viahttp://www.ruby-forum.com/.
If you want to use regexp, a quick and dirty way would be :
(a.split %r{</?p>})[1]
or:
irb(main):001:0> a = ‘aabbcc
ccddee
’ccddee
”(.*)
}, 1]–
Ittay D. [email protected]
Tikal http://www.tikalk.com
Tikal Project http://tikal.sourceforge.net
Or:
irb(main):004:0> a = ‘aabbcc
ccddee
ccceee
’ccddee
ccceee
”([^<]*)
})I perfer to specify what character(s) not to match explicitly.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs