From: Dave Thomas Date: 2001-05-30T06:36:45+09:00 Subject: [ruby-talk:15959] Re: .scan() using '/' as the regular expression delimiter "Luke Crook" writes: > I am trying to parse an Apache log file. The date field looks like: > [22/May/2001:23:54:41 -0700] > > How would I use the .scan() method when '/' is the delimiter (I'm trying to > store day, month, year as seperate fields). > I have tried \/, "/" , '/', and even [/] but these do not work. Scan is different to split: with split you specify the delimiter, whereas with scan you give the contents you want matched. So dt = "[22/May/2001:23:54:41 -0700]" fields = dt.scan(/[-\d\w]+/) # letters, digits, and minus sign fields #=> ["22", "May", "2001", "23", "54", "41", "-0700"] Regards Dave