我有以下字符串:
hum = "\\w*h(u|v|\\|_\\||\\/)(m|\\/\\\\\\/\\\\)\\w*"
它被转储到以下正则表达式中:
"I like to hu/\\/\\ every day.".gsub /#{hum}/i, 'sing'
=> "I like to sing every day."
有用。但后来我这样做:
"I like to hu/\\/\\ every day.".gsub /#{hum}\b/i, 'sing'
=> "I like to hu/\\/\\ every day."
我所做的只是\b
在#{hum}
. 并且字符串中有一个非单词字符。有什么问题?