How can I convert the string russ(ai)(edocn)cup to russiancodecup using Ruby?
How can I convert the string russ(ai)(edocn)cup to russiancodecup using Ruby?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
By using
gsubwith a block, you can replace any match of a regular expression by the result of this block.Here the regular expression will match any non-
)character between brackets. Then it will sendreverseto$1which is gonna be the content between brackets.$0will be the complete match and$n, the nth “submatch”. (anybody for the correct word ?)