lib/string_extensions.rb in royw-roys_extensions-0.0.2 vs lib/string_extensions.rb in royw-roys_extensions-0.0.3

- old
+ new

@@ -22,9 +22,17 @@ def escape_unicode self.each_byte.collect{|c| c.to_i > 127 ? "%#{c.to_i.to_s(16)}" : c.chr}.join('') end end + my_extension("remove_punctuation") do + # == Synopsis + # remove punctuation the shouldn't be in file names + def remove_punctuation + self.gsub(/([\?\:\!\"\'\,\.\-\/\*\~\;\@\#\$\%\^])/, ' ').gsub(/\s+/, ' ').strip + end + end + my_extension("strip_tags") do # == Synopsis # remove angle bracket tags from the string def strip_tags gsub(/<\/?[^>]*>/, "")