[Jprogramming] Swap first/last names

Raul Miller rauldmiller at gmail.com
Thu Aug 21 03:59:42 HKT 2008


On Wed, Aug 20, 2008 at 3:44 PM, Henry Rich <HenryHRich at nc.rr.com> wrote:
> I need the regex command that will change
> Henry Rich xxx
> to
> Rich, Henry xxx
> (each name is terminated by a single space)

   require'regex'
   s=: 'Henry Rich xxx'
   p=: '(\w+) (\w+) (\w+)'
   p rxmatch s
 0 14
 0  5
 6  4
11  3
    p (}. at rxmatch rxcut ]) s
++-----+-+----+-+---+
||Henry| |Rich| |xxx|
++-----+-+----+-+---+
    4 0 3 2 5 6 ;@:{ p (','; }. at rxmatch rxcut ]) s
Rich, Henry xxx

-- 
Raul


More information about the Programming mailing list