regex - JavaScript: Replace last occurrence of forward slash -
i've tried fiddling with
replace(/_([^_]*)$/,replacement+'$1') from post can't work
i have string:
<div class="plus"></div><div class="details"></div>text1/text2 that want transform into
<div class="plus"></div><div class="details"></div>text1/<br>text2 but keep getting / in /div replaced well
anyone?
edit: clear want replace last
"/" with
"/<br>" only last occurance.
i dunno... maybe i'm better off going in code , try replace slash before prepending html...
use lastindexof() method
var index = str.lastindexof('/'); str = str.substr(0, index + 1) + "<br>" + str.substr(index + 1); here fiddle
Comments
Post a Comment