I have been perusing the documentation for String
today, and I saw the :sub
method, which I'd never noticed before. I've been using :gsub
and it appears that they are essentially the same. Can anyone explain the difference to me? Thanks!
Ruby – the difference between gsub and sub methods for Ruby Strings
rubystring
Related Topic
- Ruby – the difference between include and require in Ruby
- Python – the difference between encode/decode
- Regex – Difference between \A \z and ^ $ in Ruby regular expressions
- C# – Split a string by another string in C#
- Php – the difference between single-quoted and double-quoted strings in PHP
- Postgresql – Difference between text and varchar (character varying)
- Ruby – What’s the difference between equal?, eql?, ===, and ==
- Ukkonen’s suffix tree algorithm in plain English
Best Answer
The
g
stands for global, as in replace globally (all):In irb: