say i have the string “qxq” and i want to repeat the middle char 4 times
i could do this
str = "qxq
newstring = str.gsub(/(x)/, ‘\1’*4)
but if i have a string full of x’s i.e. “xxx”
then it will repeat all of them 4 times and thats not what i want to
do…i just want the middle one to be repeated.
How do i alter that regex to do this???