Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Re: Txet Maglning Glof, Ayobndy?

by halley (Prior)
on Sep 16, 2003 at 14:12 UTC ( [id://291824]=note: print w/replies, xml ) Need Help??


in reply to Re: Txet Maglning Glof, Ayobndy?
in thread Txet Maglning Glof, Ayobndy?

As pointed out, this misses apostrophes. I don't mind missing those. But we can chop even more.
perl -pe 's:\B(\w)(\w+)\B:$2$1:g' # ------------------------ # 12345678 1 2345678 2 234

--
[ e d @ h a l l e y . c c ]

Replies are listed 'Best First'.
Re: Txet Maglning Glof, Ayobndy?
by Abigail-II (Bishop) on Sep 16, 2003 at 14:17 UTC
    It misses out on apostrophes because the original question didn't deal with them either. It wasn't specified how those should be handled. Note that it's fairly trivial to replace \w with [\w'], as long as you don't use \B or \b.

    Abigail

Re: Re: Re: Txet Maglning Glof, Ayobndy?
by InfiniteSilence (Curate) on Sep 16, 2003 at 15:28 UTC
    Maybe I am doing something wrong, but I tried your one-liner and it does not work:
    perl -pe 's:\B(\w)(\w+)\B:$2$1:g' According to a research at an English university, it doesn't matter in + what orde r According to a research at an English university, it doesn't matter in + what orde r
    It just reprinted the exact same line I typed in.

    Celebrate Intellectual Diversity

      If you're on Windows, use double-quotes on the command line. If you're on any Un*x variety, including cshell and bash on Solaris and Linux, use the single-quotes as given.

      Every command shell differs in what needs escaping, and what is seen as one argument, or two arguments. However, many people playing golf seem to prefer the Un*x varieties. Maybe it's because Un*x has inspired golf since its inception: cp instead of copy; mv instead of move; ln instead of link; etc.

      Know your command shell.

      --
      [ e d @ h a l l e y . c c ]

      Shells often play tricks on us all -> `perldoc perlrun' -> On some systems, you may have to change single-quotes to double ones
      C:>perl -pe s:\B(\w)(\w+)\B:$2$1:g According to a research at an English university, it doesn't matter in + what order Acordincg to a rsearceh at an Eglisnh uiversitny, it deson't mttear in + waht oderr One two three four, NodeReaper is gonna score! One two trehe fuor, NdeReapeor is gnnoa sorce! ^Z

      MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
      I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
      ** The third rule of perl club is a statement of fact: pod is sexy.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://291824]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-03-29 08:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found