Regular expression problem

S

sujeet kumar

hi
I want to sepearte a pattern from a string using regular expression
and scan. String is
str =3D "<font color=3D#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 -=20

How to do this.
i tried like
str =3D "<font color=3D#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
 
N

Nikolai Weibull

sujeet said:
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
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top