This is really simple question but rarely use regex’s so I apologize. I am writing a simple view helper for some simple UBBcodes
I want t o be able to call:
<%=arc_format "[quote]hello you from me[\quote]" %>
and have it return:
<div class='start-quote'>
hello you from me
</div>
my helper:
def arc_format str
str=str.gsub(/\[quote\]/,'<div class="start-quote">') # works but adds in second quote; seems to hit off second isntance
str=str.gsub!(/\[\\quote\]/,'</div>')
str.html_safe
end
the output is
<div class='start-quote'>
hello you from me
<div class='start-quote'>
</div>
How do I get that second regex from not replacing?
thx in advance
The backslash is not being carried over. Try:
Should be:
Is it supposed to be
[\quote]? I would have thought[/quote]makes more sense.