Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
How do I rearrange the characters in '3 4 +' to '3 + 4' using regexp? I've written the following:
puts ('3 4 +').gsub(/\d \d \W/, '\1 \3 \2')
But nothing is being printed. What am I doing wrong?
您需要通过().
()
'3 4 +'.gsub /(\d+) (\d+) (\W)/, '\1 \3 \2'