strs = ["abc", "ab+c", "+abc", "-+abc", "ab+-c"]strs.each { |x| p x.gsub(/(?!\A)[-+~]/, "") }
Standard input is empty
"abc" "abc" "+abc" "-abc" "abc"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!