Reputation: 2594
@content = "<p><span style=\"font-family: 'trebuchet ms', 'geneva'; font-size: 'large';\">Helo's</span></p>"
I want to remove single quotes ('
) from <style>
but not from the Helo's
. Right now I'm using this but this remove all the single quotes('
).
@content.gsub(/'/,"")
Upvotes: 1
Views: 2053
Reputation: 46846
You could do:
@content.gsub(/style=".+?"/){ |x| x.gsub("'", '') }
This would remove the single quotes from the style attributes.
Upvotes: 2
Reputation: 2880
Seems like you are going to need to parse the HTML with something like nokogiri. Only then you will be able to replace the text content of the tags.
Upvotes: 1