lib/email_reply_parser.rb
# reverses parentheses in a string 
#
# text - String or Regexp that you want to reverse
#
# Returns String
reverses parentheses in a string
text - String or Regexp that you want to reverse

Returns String
reverses parentheses in a string text - String or Regexp that you want to reverse Returns String
def reverse_parentheses(text)
      text.gsub!(/\)(.*)\(/m, '(\1)')  
      text.gsub!(/\)(.*?)\(/m, '(\1)')  
      text
    end
def reverse_parentheses ( text ) text . gsub! ( / \) (.*) \( /m , '(\1)' ) text . gsub! ( / \) (.*?) \( /m , '(\1)' ) text end
reverses parentheses in a string
text - String or Regexp that you want to reverse
reverses parentheses in a string text - String or Regexp that you want to reverse
#reverses outter parentheses #reverses nested parentheses
text