. | ( ) [ ] { } + \ ^ $ * ?
a = /a/ a.class # Regexp myString = "A woman once said. A man once said. A child once said" match = myString.match(a) #this will return a match = myString.scan(a) #this will return ["a", "a", "a", "a", "a"] match = myString.gsub(a,"b") #this will replace all a(s) with b, leaving behind capital A myString =~ a #return the index of the first occurance match = myString.split(a) # split a string by a(s)
(?<month>\d{1,2})\/(?<day>\d{1,2})\/(?<year>\d{4})
Then we can do something like this:
date_string = "06/11/1985" pattern = /(?<month>\d{1,2})\/(?<day>\d{1,2})\/(?<year>\d{4})/ result = date_string.match(pattern) # we can now access the days, month and year result[:day] #11 result[:month] #06 result[:year] #1985
(?<month>\d{1,2})\/(?<day>\d{1,2})\/(?<year>\d{4})