Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

ruby regex replace capture group

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)/, '.')
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #ruby #regex #replace #capture #group
ADD COMMENT
Topic
Name
1+5 =