Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Regular Expressions with Ruby

Regular Expressions with Ruby

What Do You Know? Sydney, 03 April, 2014

Elle Meredith

April 03, 2014
Tweet

More Decks by Elle Meredith

Other Decks in Technology

Transcript

  1. MatchData string = "The quick brown fox jumps over the

    lazy dog” ! matchdata = string.match /fox/ => #<MatchData "fox">
  2. Look Around string = ''' I love my job, I

    love the pay! I love it more and more each day. I love my boss, he is the best! I love his boss and all the rest. '''
  3. Changing things string.gsub(/love/, 'hate') => "\nI hate my job, I

    hate the pay! \nI hate it more and more each day.\nI hate my boss, he is the best!\nI hate his boss and all the rest.\n"
  4. Changing things string.gsub!(/\she/, ' she').gsub!(/ his/, ‘her') => "\nI love

    my job, I love the pay! \nI love it more and more each day. \nI love my boss, she is the best!\nI love her boss and all the rest.\n"