From: kyu Date: 2005-04-21T01:54:54+09:00 Subject: Re: Another(!!) Newbie question Ryan Leavengood wrote: >Here is a very simple (maybe naive) regular expression to use to parse >this data: > >/^:(.*)!(.*) (.*) #(.*) :(.*)$/ > >An example of using this: > >def parse_irc_data(data) > if data =~ /^:(.*)!(.*) (.*) #(.*) :(.*)$/ > puts "Part 1: #$1" > puts "Part 2: #$2" > puts "Part 3: #$3" > puts "Part 4: #$4" > puts "Part 5: #$5" > end >end > >parse_irc_data(":kyu!kyu@cpimps-34E00F11.elk.dialup.pol.co.uk PRIVMSG >#matrix :yea that's it") > >The output: >Part 1: kyu >Part 2: kyu@cpimps-34E00F11.elk.dialup.pol.co.uk >Part 3: PRIVMSG >Part 4: matrix >Part 5: yea that's it > >Regards, >Ryan Leavengood > >kyu wrote: > > >>Hi guys, i'm writing a simple irc bot to get to grips with what i've >>learned about ruby so far. >>It works ok, but i'm looking for a simple way to format the output, at >>the moment the log files and stdout >>look something like this: >> >>:kyu!kyu@cpimps-34E00F11.elk.dialup.pol.co.uk PRIVMSG #matrix :yea that's >>it >> >>I read the pickaxe section on regexp thinking that would point me in the >>right direction but i'm still not sure. >> >>Any help would be great. Thanks. >> >> -kyu >> >> > > > > Thanks alot! It always seems so simple after someone answers your question, i'll re-read that section and hopefully figure out how it works a bit more. -kyu