# Encode the string by UBB
Def ubb_encode (source_str)
Source_str.scan (/ /) Do | v |
If v. match (/src = ["']. *? ["']/)! = Nil
Source_str = source_str.sub (v, '[img' + v. match (/src = ["']. *? ["']/) [0] +'/] ')
End
End
Source_str.scan (/<span [] *?. *?> /) Do | span |
Style = span. match (/style = ["']?. *? ["']/). To_s
Source_str = source_str.sub (span, '[span' + style + ']')
End
Source_str = source_str.gsub (/background-image .*? \)/,'')
Source_str = source_str.gsub ('</span>', '[/span]')
Source_str = source_str.gsub (/<strong> | <B>/, '[B]'). gsub (/<\/strong> | <\/B>/, '[/B]')
Source_str = source_str.gsub (/<br [] *?. *? [\/]?> /, '[Br/]')
Source_str = source_str.gsub (/<u>/, '[u]'). gsub (/<\/u>/, '[/u]')
Source_str = source_str.gsub (/<em> | <I>/, '[I]'). gsub (/<\/em> | <\/I>/, '[/I]')
Source_str = source_str.gsub (/<p>/, '[p]'). gsub (/<\/p>/, '[/p]')
Return source_str
End
# Decoding strings by UBB without retaining HTML code
Def ubb_decode (source_str)
Source_str.gsub (/<script. *?>. *? <\/Script>/, ''). gsub (/<. *?> /, ''). Gsub ('[', '<'). gsub (']', '>'). gsub ('& quot ;','"')
End