Top "Gsub" questions

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

Use gsub remove all string before first white space in R

I have a data frame like this: name weight r apple 0.5 y pear 0.4 y cherry 0.1 g watermelon 5.0 pp grape 0.5 y …

regex r gsub
Convert numbers to letters

I have the following vector: x <- c(11, 12, 21, 22) And I want to convert it to the corresponding letters, i.…

string r replace gsub
Ruby gsub doesn't escape single-quotes

I don't understand what is going on here. How should I feed gsub to get the string "Yaho\'o"? >&…

ruby escaping gsub
Remove specific last character from string

I have following string vector: EC02 502R 603 515 602 KL07 601 511R 505R 506R 503 508 514 501 509R 510 501R 512R 516 507 604 502 601R SPK01 504 504R ACK01 503R 508R 507…

r regex gsub
Shorter way to remove non-characters than gsub(/\d|\W/, "")

my_string = 'Here's the #: 49848! - but will dashes, commas & stars (*) show?' puts src.gsub(/\d|\W/, "") i.e. …

ruby regex string gsub string-substitution
Match and replace multiple strings in a vector of text without looping in R

I am trying to apply gsub in R to replace a match in string a with the corresponding match in …

r string gsub
Formatting month abbreviations using as.Date

I'm working with monthly data and have a character vector of dates, formatted: Sep/2012 Aug/2012 Jul/2012 and so on, back …

r date gsub
How do I gsub an empty "" string in R?

How do I replace an empty string? This: x = c("","b") gsub("","taco",x) produces: "taco" "tacobtaco" instead of: "taco" "…

r gsub
Removing parenthesis in R

I am trying to remove parentheses from a string value in this case this one: (40.703707008, -73.943257966) I can't seem to …

r regex gsub
How to replace multiple strings with the same in R

I have a string vec = c('blue','red','flower','bee') I want to convert different strings into the same in …

r string replace gsub