Top "Gsub" questions

Ruby, Lua, R and Awk methods for performing a global pattern substitution.

Ruby regex what does the \1 mean for gsub

What does the \1 do? For example "foo bar bag".gsub(/(bar)/,'car\1') I believe it has something to do …

ruby regex gsub
In R, how do I replace a string that contains a certain pattern with another string?

I'm working on a project involving cleaning a list of data on college majors. I find that a lot are …

string r expression gsub
How can I remove non-numeric characters from strings using gsub in R?

I use the gsub function in R to remove unwanted characters in numbers. So I should remove from the strings …

r regex gsub
Ruby, gsub and regex

Quick background: I have a string which contains references to other pages. The pages are linked to using the format: "#12". …

ruby-on-rails ruby regex gsub
Escaping strings for gsub

I read a file: local logfile = io.open("log.txt", "r") data = logfile:read("*a") print(data) output: ... "(\.)\n(\w)", …

lua gsub
R gsub a single double quotation mark

I have a field of strings in a data frame all similar to: "Young Adult – 8-9"" where the inner single " …

regex r escaping gsub
How to backreference in Ruby regular expression (regex) with gsub when I use grouping?

I would like to patch some text data extracted from web pages. sample: t="First sentence. Second sentence.Third sentence." …

ruby regex reference gsub backreference
R regex gsub separate letters and numbers

I have a string that's mixed letters and numbers: "The sample is 22mg" I'd like to split strings where a …

regex r gsub stringr
Ruby regex- does gsub store what it matches?

If i use .gsub(/matchthisregex/,"replace_with_this") does gsub store what it matches with the regex somewhere? I'd like …

ruby regex gsub
How to replace the characters in a string

I have a method that I want to use to replace characters in a string: def complexity_level_two replacements = { …

ruby string gsub