Regular expressions are widely used in the daily work of developers. For example, I can use the gsub method when I want to replace all the vowels in a given string with the underscore symbol:
"here will be dragons".gsub(/([aeiouy])/, "_") => "h_r_ w_ll b_ dr_g_ns"
The question is how to wrap each matched vowel with the underscore. The first solution is to use the back-reference in a replacement argument: