[ create a new paste ] login | about

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

minitech - Ruby, pasted on Jan 26:
1
2
3
4
string = 'this_should_not have emphasis but _this_ one should. **Strong emphasis**'
string.gsub!(%r{(^|\s)(\*\*|__)(.+?)\2(\s|$)}x, %{\\1<strong>\\3</strong>\\4})
string.gsub!(%r{(^|\s)([*_])(.+?)\2(\s|$)}x, %{\\1<em>\\3</em>\\4})
puts string


Output:
1
this_should_not have emphasis but <em>this</em> one should. <strong>Strong emphasis</strong>


Create a new paste based on this one


Comments: