Learning Ruby 6 - PowerPoint PPT Presentation

About This Presentation
Title:

Learning Ruby 6

Description:

Very useful when working with textual data. Similar technology available in Perl, C#, Python and Java (to name a few) ... target, regex = ARGV.collect { |arg ... – PowerPoint PPT presentation

Number of Views:75
Avg rating:3.0/5.0
Slides: 5
Provided by: glasnost
Category:
Tags: argv | learning | ruby

less

Transcript and Presenter's Notes

Title: Learning Ruby 6


1
Learning Ruby - 6
  • Regular Expressions

2
Ruby's Regex Technology
  • Specifying what you are after using a terse,
    compact syntax
  • Very useful when working with textual data
  • Similar technology available in Perl, C, Python
    and Java (to name a few)
  • Think of regex's as a programming technology
    within a programming technology
  • Refer to the handout "Paul's Ruby Regex Primer"

3
A Useful Ruby Regex Processor
  • ! /usr/bin/ruby -w
  • def show_regexp( target, regex )
  • Based on the code from page 69, Programming
    Ruby,
  • 2nd Edition by Dave Thomas.
  • if target regex
  • "gtgtltlt'"
  • else
  • "no match found"
  • end of if.
  • end of show_regexp.
  • target, regex ARGV.collect arg arg
  • regex Regexp.new( regex )
  • puts show_regexp( target, regex )

4
More ... Ruby So Far
  • Take the time to learn Ruby's regular expression
    syntax
Write a Comment
User Comments (0)
About PowerShow.com