📜  ruby 正则表达式替换捕获组 - Ruby 代码示例

📅  最后修改于: 2022-03-11 15:04:50.185000             🧑  作者: Mango

代码示例1
You can't. gsub replaces the entire match; it does not do anything with the captured groups. It will not make any difference whether the groups are captured or not.
In order to achieve the result, you need to use lookbehind and lookahead.

"5,214".gsub(/(?<=\d),(?=\d)/, '.')