Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

gsub

Ruby gsub doesn’t escape single-quotes

January 7, 2024 by Tarik

\’ means $’ which is everything after the match. Escape the \ again and it works “Yaho’o”.gsub(“‘”, “\\\\'”)

Categories ruby Tags escaping, gsub, ruby Leave a comment

Using named capture groups inside Ruby gsub blocks (regex)

December 26, 2023 by Tarik

You are looking for “foo /(bar)”.gsub(/(?<my_word> \(.*?\) )/x) do |match| puts “$1 = #{$1} and $my_word = #{$~[:my_word]}” end

Categories ruby Tags gsub, regex, ruby Leave a comment

Remove all punctuation except apostrophes in R

December 22, 2023 by Tarik
Categories r Tags gsub, punctuation, r, regex Leave a comment

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

December 9, 2023 by Tarik
Categories r Tags gsub, r, regex Leave a comment

Remove pattern from string with gsub

September 9, 2023 by Tarik
Categories r Tags gsub, r Leave a comment

Ruby match first occurrence of string for a gsub replacement

August 30, 2023 by Tarik

Use sub, not gsub. gsub is global, sub isn’t.

Categories ruby Tags gsub, regex, ruby, string-substitution Leave a comment

Replace multiple strings in one gsub() or chartr() statement in R?

July 21, 2023 by Tarik
Categories r Tags character-replacement, gsub, r, string Leave a comment

Removing Whitespace From a Whole Data Frame in R

May 29, 2023 by Tarik
Categories r Tags gsub, r, replace, whitespace Leave a comment

Remove parenthesis from a character string

May 15, 2023 by Tarik
Categories r Tags gsub, r, string Leave a comment

Lua String replace

April 20, 2023 by Tarik

Try: name = “^aH^ai” name = name:gsub(“%^a”, “”) See also: http://lua-users.org/wiki/StringLibraryTutorial

Categories string Tags gsub, lua, lua-patterns, replace, string Leave a comment
Older posts
Page1 Page2 Next →

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa