From: Marnen Laibow-Koser Date: 2010-02-12T03:27:39+09:00 Subject: Re: n00b: text processing from magnetic stip input John Gesimondo wrote: > Hello everyone! > > I'm trying to make a program and I'm really bad at text processing. Then you will have to get better. :) > The > input is a magnetic stripe of a card (coming straight off a card > reader). I'm trying to split the output so that each part can get stored > in a variable. > > Here's what comes off the card: > %B6007503004905860^GEVIMSEDO/JRPN > P^894212333300?;604750230190488515=993612044400050600?+E? > > And here's what I want (with relevant details): > > iso = 6007503004905860 [always the same length] > > last_name = Gevimsedo [variable length, always following carrot symbol] > > first_name = Jrpn [variable length, always after slash] > > middle_name = P [ either one letter, or non-existent after frist name > separated by a space] > > > If anyone could make that happen, you'd make my day/week/etc. Do you mean that you expect us to write your core processing code for you? If so, that's not cool. We can help, but you'll have to do the work yourself. > I've been > trying for a while, but I'm clearly too much of a n00b. > > :) Step 1: Write specs with RSpec (or similar library) defining the desired behavior. Step 2: Read the documentation for classes String and Regexp. Step 3: Make the tests pass. If you have problems, share what you've done and we'll be happy to help. Good luck! Best, --  Marnen Laibow-Koser http://www.marnen.org marnen@marnen.org -- Posted via http://www.ruby-forum.com/.