>#{$&}<<#{$'}" 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 ) A Useful Ruby Regex Processor"> >#{$&}<<#{$'}" 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 ) A Useful Ruby Regex Processor">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

Learning Ruby - 6 Regular Expressions. Ruby's Regex Technology Specifying what you are after using a terse, compact syntax Very useful when working with.

Similar presentations


Presentation on theme: "Learning Ruby - 6 Regular Expressions. Ruby's Regex Technology Specifying what you are after using a terse, compact syntax Very useful when working with."— Presentation transcript:

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 #! /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 "#{$`}>>#{$&}<<#{$'}" 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 ) A Useful Ruby Regex Processor

4 More... Ruby So Far Take the time to learn Ruby's regular expression syntax


Download ppt "Learning Ruby - 6 Regular Expressions. Ruby's Regex Technology Specifying what you are after using a terse, compact syntax Very useful when working with."

Similar presentations


Ads by Google