It will either match fail or repeat as a whole. A1 gsub d 2 a2. Think about an email address with a ruby regex you can define what a valid email address looks like.