Regular Expressions to the Rescue

Working my way through the Launch School curriculum and I had nearly forgotten how much I love regular expressions! Look at how beautiful this is:

def valid_number?(num)
  num =~ /\-?\d+\.?\d*f?/
 end

It’s just lovely. The most wonderful site, Rubular was a huge help in working out the details. It’s a terrific little sandbox that allows you to test out our regular expressions in Ruby. You can see exactly what you’re picking up and exactly what you’re leaving behind and it’s wonderful. I could easily spend all day there.

Ok, back to work now.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s