[ create a new paste ] login | about

Link: http://codepad.org/szLL2eFU    [ raw code | output | fork ]

minitech - Ruby, pasted on Jan 25:
1
2
3
string = 'this should have _emphasis_ but this_one_should_not'
string.gsub!(%r{(^|\s)([*_])(.+?)\2(\s|$)}x, %{\\1<em>\\3</em>\\4})
puts string


Output:
1
this should have <em>emphasis</em> but this_one_should_not


Create a new paste based on this one


Comments: