Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Swap Input lines

by trizen (Hermit)
on Apr 19, 2012 at 09:31 UTC ( #965898=note: print w/replies, xml ) Need Help??

in reply to Swap Input lines

$output_line = "$3$2$1" if $input_line =~ /^([a-z][a-z\s]*[a-z])(\W+)(\d[\d-]*\d)$/i;
It accepts input like this:
Mary Smith = 345-78-9090 Joseph Alioto 976-83-1234
and the output will be:
345-78-9090 = Mary Smith 976-83-1234 Joseph Alioto

Replies are listed 'Best First'.
Re^2: Swap Input lines
by brx (Pilgrim) on Apr 19, 2012 at 10:09 UTC
    This is a detail, but this regex  /^([a-z][a-z\s]*[a-z])(\W+)(\d[\d-]*\d)$/i is too specific.
    Input file contains lines with "x=y" format, so we must only search for "=" -- see jwkrahn's contribution: Re: Swap Input lines.
    Here some examples where this regex doesn't match:
    Jean-Paul Goude = 22-22 Marcel Duchamp = One-Two-Two Victoire Passage = 118_218 Philip K. Dick = 123-456
      You are right. I misunderstood the OPs problem.
Re^2: Swap Input lines
by JavaFan (Canon) on Apr 19, 2012 at 10:22 UTC
    So, you're swapping around pieces of the input, even on lines that do not contain a =? And on the other hand, you don't swap around input on lines that do contain a =, but don't match a regexp you distilled from looking at two examples? Yet, you still allow many other lines that aren't either the first, or the second example.

    That's an, uhm, "interesting" way of answering the question. I wonder whether it's helpful.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://965898]
and the sunlight beams...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2017-08-22 05:50 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (329 votes). Check out past polls.