Search
 
SCRIPT & CODE EXAMPLE
 

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)/, '.')
Comment

PREVIOUS NEXT
Code Example
Ruby :: rails api render show page with id 
Ruby :: cant find user without id error in rails 
Ruby :: common functions in rails 
Ruby :: self join relationship rails 
Ruby :: rails check log level of application 
Ruby :: set db environment to development 
Ruby :: ruby find frequency in array self.all 
Ruby :: how to comment out embedded ruby 
Ruby :: ruby file copy 
Ruby :: ruby hash from array 
Ruby :: ruby decode base64 
Ruby :: ruby if statement 
R :: vertical line in ggplot2 
R :: automatically wrap r text label ggplot 
R :: r extract everything before character 
R :: line split r 
R :: r replace blank string with na 
R :: r pipe 
R :: custom function in r 
R :: r merge columns 
R :: calculating RMSE, Rsquared with caret in R 
R :: subset row r 
R :: how to interpolate missing data in r 
R :: r function to get class of all columns 
R :: summary metrics of confusion matrix 
R :: count equal values in a vector 
R :: count certain number of alphabets in a string r 
R :: Significance codes 
R :: r produce 10 alphabet 
R :: how to remove all attributes from a variables in r 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =