Robert Klemme
10/1/2004 7:45:00 AM
"Mark Probert" <probertm@nospam-acm.org> schrieb im Newsbeitrag
news:Xns95749654816D0probertmnospamtelusn@198.161.157.145...
> Hi ..
>
> Simon Strandgaard <neoneye@adslhome.dk> wrote:
> >
> > How about something ala
> >
> > irb(main):015:0> "aa;bbb\\;;abc;;d\\\\;e;".scan(/(?:\\[^.]|[^;])*;/)
> > => ["aa;", "bbb\\;;", "abc;", ";", "d\\\\;", "e;"]
> >
>
> Thanks! That is close enough:
>
> irb(main):019:0> s.scan(/(?:\\[^.]|[^;])*/).each do |it|
> irb(main):020:1* next if it.empty?
> irb(main):021:1> puts " --> #{it}"
> irb(main):022:1> end
> --> a is a word
> --> b is too
> --> c\; for fun
> --> d -- forget it
> => ["a is a word", "", "b is too", "", "c\\; for fun", "", "d -- forget
> it", "", ""]
>> s = "aa;bbb\\;;abc;;d\\\\;e;"
=> "aa;bbb\\;;abc;;d\\\\;e;"
>> s.scan /(?:\\.|[^\\;])+/
=> ["aa", "bbb\\;", "abc", "d\\\\", "e"]
Regards
robert