0
這真的很簡單的問題,但很少使用正則表達式,所以我很抱歉。我寫一些簡單的UBBcodesgsub和打在正則表達式,我不想在鐵幫助
我希望能夠調用一個簡單的視圖助手:
<%=arc_format "[quote]hello you from me[\quote]" %>
,並使其返回:
我的幫助:
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
輸出是
<div class='start-quote'>
hello you from me
<div class='start-quote'>
</div>
如何從不替換第二個正則表達式?
thx預先
對不起,已經是那些早上的其中之一,你對結束斜線是正確的 – timpone
簡單的錯誤。我們都做他們。 –