Re: Ruby Regular Expression Regular expressions are used for matching certain patterns, so for example, if you use \d then this will try to match a digit, if you use \s, this will match a space character.
Let me now give you an example on how you use regular expressions:
johnsays = “It's 9:18PM here now.I cannot wait to go out tonight.”
time = /\d\d:\d\d/
if johnsays=~time
puts “John told you what time it is.He is eager to go out.”
else
puts “John does not care what time it is.He is too tired to go out.”
end
__________________ Shaalini.S Be the Best of Whatever you are...
Last edited by shaalini : 04-24-2008 at 01:49 AM.
|