lib/sugar-high/string.rb in sugar-high-0.4.0 vs lib/sugar-high/string.rb in sugar-high-0.4.3
- old
+ new
@@ -1,5 +1,10 @@
class String
+ # remove prefixed '-' signs, then allow any letter, number, underscore '_' or dash '-'
+ def alpha_numeric
+ self.gsub(/^\-+/, '').gsub(/[^0-9a-zA-Z_\-]+/i, '')
+ end
+
def insert_before_last str, marker = 'end'
res = []
found = false
marker = case marker
when Symbol, String
\ No newline at end of file