home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / perl / 5806 < prev    next >
Encoding:
Text File  |  1992-09-09  |  1.3 KB  |  56 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!fmrco!fmrco!asherman
  3. From: asherman@laser.fmrco.com (Aaron Sherman)
  4. Subject: Re: stupid questions : deleted ing leading spaces
  5. In-Reply-To: jhd@irfu.se's message of 7 Sep 92 06:26:49 GMT
  6. Message-ID: <ASHERMAN.92Sep9160424@laser.fmrco.com>
  7. Sender: news@fmrco.uucp
  8. Reply-To: asherman@fmrco.COM
  9. Organization: I-Kinetics, 19 Bishop-Allen Dr., Cambridge, MA
  10. References: <1992Sep7.022351.1137@unilabs.uucp> <1992Sep7.062649.20540@irfu.se>
  11. Date: Wed, 9 Sep 1992 21:04:24 GMT
  12. Lines: 42
  13.  
  14.  
  15. >>>>> jhd@irfu.se (Jan D.) said:
  16.  
  17. jhd> chare@unilabs.uucp (Chris Hare) writes:
  18.  
  19. >As a matter of of fact, if you can suggest a way to remove the leading
  20. >spaces, and compact multiple spaces any where else on the line to be one
  21. >space I'd appreciate it.
  22. >
  23.  
  24. jhd>     s/^ //;
  25. jhd>     s/ +/ /g;
  26.  
  27. jhd> If you want to replace general white space (i.e. tabs and space)
  28. jhd> you should say:
  29.  
  30. jhd>     s/^\s//;
  31. jhd>     s/\s+/ /g;
  32.  
  33. s/^\s+//;    # or s/^ +//; for just spaces.
  34. s/\s+/ /g;    # or s/ +//g; for just spaces.
  35.  
  36. Otherwise:
  37.  
  38.     "       Hello, world!"
  39.  
  40. turns into:
  41.  
  42.     " Hello, world!"
  43.  
  44. Not:
  45.  
  46.     "Hello, world!"
  47.  
  48.  
  49.             -AJS
  50.  
  51. --
  52. --------
  53. Disclaimer: I am solely responsible for the content of this message.
  54. The views expressed here may not be the views of I-Kinetics, Fidelity,
  55. any of the Fidelity-owned corporations or my mother.
  56.