Regexp Help

J

Jillian Kozyra

Hi,

I am looking for a way to do the following:

I have some html in strings, mostly links (i.e. <a
href="http://mysite.com">). I need to delete these lines. I've been
trying to do this, but it's not working out:

question.gsub! ("<a href=\"\/([.]+)\/\" >$/i", "")
or also: question.gsub! ("<a href=\"\/([a-zA-z0-9]+)\/\" >$/i", "")

(and various permutations of these two).

How would one go about this?

Thanks,
Jillian
 
7

7stud --

Jillian said:
Hi,

I am looking for a way to do the following:

I have some html in strings, mostly links (i.e. <a
href="http://mysite.com">). I need to delete these lines. I've been
trying to do this, but it's not working out:

question.gsub! ("<a href=\"\/([.]+)\/\" >$/i", "")
or also: question.gsub! ("<a href=\"\/([a-zA-z0-9]+)\/\" >$/i", "")

(and various permutations of these two).

How would one go about this?

Thanks,
Jillian

q = 'Hello <a href="http://mysite.com">world<a
href="http://mysite.com">.'

result = q.gsub(/<a.*?>/, "")
puts result

--output:--
Hello world.
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top