Ad
  • Custom User Avatar

    Using gsub! would only apply the subtitution once, so '(({}))' would go to -> '(())'
    The while loop continues until gsub returns a falsey value, at which point the string is either empty or the match could not be found.