Tag Archives: regular expressions

Regular Expressions in Ruby (and Rails)

How does Rails, or rather, Ruby, deal with Regular Expressions? There are a few things; first, the syntax for regular expressions is a bit unique in Ruby. Second, the String class has a few methods that you can use for regular-expression use–namely match and gsub, which you can use to match (groups) and access matches. Continue reading

Posted in Development | Tagged , | 19 Comments

String Replacement in Ruby

How can you replace strings in Ruby? There are a couple of options; there’s the tr function, which takes two sets of characters, and substitutes them; and there’s the gsub method, which makes a global replacement based on a regular expression. Powerful stuff! Continue reading

Posted in Development | Tagged , , | Comments Off