From: "Daniel Völkerts" Date: 2004-08-17T01:06:06+09:00 Subject: Re: Rubish Way of extracting elements David A. Black wrote: > You could match it to a regular expression, and grab the results in > ()-expressions: > > str = "<165> Aug 16 17:01:35 localhost Just a test" > > pri, timestamp, device, msg = > /<(\d+)>\s+(\w+\s+\d+\s+[\d:]+)\s+(\S+)\s+(.*)/.match(str).captures > > Another way would be to use scanf. This has the advantage that you > get your 165 as an integer (if that's important): > > require 'scanf' > pri, timestamp, device, msg = str.scanf("<%\d> %15c %s%*c %[\\S\\s]" > > > (You might have to adjust either the regex or the format string > depending on how consistent and predictable the lines are.) Thanks a lot. Thats the way I would expect it. Simple and nice to understand. I'll try it. Many regards. -- Daniel V�lkerts :: "Ich habe einen Drachen, und ich WERDE ihn benutzen!" - Esel in Shrek