Skip to content

Details

Come on out and hack!

Let's get some practice with regular expressions. Some people find them intimidating but they're wonderful once you get used to them. We'll try some simple regular expressions like this /[0-9]{5}(-[0-9]{4})?/ and some more complex ones, too.

All levels of Ruby expertise are welcome, including beginners. We'll pair up to do the Ruby coding.

Just bring yourself and a laptop with Ruby installed. This meetup will be more fun if you have Ruby version 1.9.2 (or 1.9.3 if it's out by 10/20!) installed.

Our host, Enova Financial, will provide food and drink.

See you there!

Write regexp in irb:
Ruby to see if a string matches a regular expression: "abcde" =~ /abc/
Ruby to return a modified a string: "abcdef".gsub(/[aeiou]/,'*')
Ruby to return regex MatchData: match_data = /abc/.match("aabcdef")

Or in:
http://rubyxp.com/ (for Ruby 1.8)
http://rubular.com/ (for Ruby 1.9)

General info on regular expressions in:
http://www.regular-expressions.info/
http://ruby-doc.org/core-1.9.2/Regexp.html
http://ruby-doc.org/core-1.9.2/MatchData.html

Some regexes we can write:

  1. all common misspellings of calendar (vowel switch a/e)

  2. remove leading and trailing whitespace

  3. valid date (matches one of these formats):
    mm/dd/yy
    m/d/yy
    m/dd/yy
    mm/d/yy
    mm/dd/yyyy
    m/d/yyyy
    m/dd/yyyy
    mm/d/yyyy
    ddmmmyy 20OCT11
    ddmmmyyyy 20OCT2011
    dmmmyy 2OCT11
    dmmmyyyy 2OCT2011
    4.valid zip code 5 digits OR 5 digits followed by - and 4 digits

5.valid hexadecimal number

6.valid floating point number

7.valid email address (and how do you define 'valid'??)

8.extract text from HTML string

this is bold text to this is bold text
9.all occurrences of the word color or colour in text (but not colorful)

10.all words in a text that are not prefixed by 'anti'

11.all words in a text that are not immediately followed by 'ing'

12.change European floating point numbers to US format 1.000,00 to 1,000.00

13.add commas to integers 10000000 to 10,000,000

Be sure to check out the ChicagoRuby Job Board (http://jobs.chicagoruby.org/). ChicagoRuby attracts some of the sharpest minds in software development. If you are building a software team, this is the audience you want to reach. If you are looking to join a team, the ChicagoRuby Job Board features employers who take team building seriously. http://jobs.chicagoruby.org (http://jobs.chicagoruby.org/)

Related topics

You may also like