hi
I want to sepearte a pattern from a string using regular expression
and scan. String is
str = "<font color=#008000>www.<b>ruby</b>central.com/ - 4k - </font><nobr>a"
patttern is the part of string that is in between "#008000> " and "</font>"
for above str pattern is www.<b>ruby</b>central.com/ - 4k -
How to do this.
i tried like
str = "<font color=#008000>www.<b>ruby</b>central.com/ - 4k - </font><nobr>a"
temp.scan(/(#008000>)(^(</font>))*(</font>)/) {|w| print "#{w} \n" }
But this gives error
Reg.rb:4: warning: Object#type is deprecated; use Object#class
How to do this.
Thanks
Sujeet
sujeet kumar wrote:
str = "<font color=#008000>www.<b>ruby</b>central.com/ - 4k - </font><nobr>a"
temp.scan(/(#008000>)(^(</font>))*(</font>)/) {|w| print "#{w} \n" }
You can use the following regular expression (which isn’t very flexible):
/#008000>(.*?)</font>/
That’ll slurp up anything from the end of the <font> to the beginning of
the </font>, so to speak.
But this gives error
Reg.rb:4: warning: Object#type is deprecated; use Object#class
That’s a warning, and it’s unrelated to your matching,
nikolai
···
--
Nikolai Weibull: now available free of charge at http://bitwi.se/\!
Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}
Hi,
What about this one ?
/<font.*?>(.*?)<\/font>/
Sorry, I didn't test it.
simonced wrote:
What about this one ?
/<font.*?>(.*?)<\/font>/
Sure, but he didn’t want to match just any <font>…</font>,
nikolai
···
--
Nikolai Weibull: now available free of charge at http://bitwi.se/\!
Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}