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

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!mcsun!sunic!corax.udac.uu.se!irfu.se!jhd
  3. From: jhd@irfu.se (Jan D.)
  4. Subject: Re: stupid questions : deleted ing leading spaces
  5. Message-ID: <1992Sep10.225848.3307@irfu.se>
  6. Date: Thu, 10 Sep 1992 22:58:48 GMT
  7. References: <1992Sep7.022351.1137@unilabs.uucp> <1992Sep7.062649.20540@irfu.se> <ASHERMAN.92Sep9160424@laser.fmrco.com>
  8. Organization: Swedish Institute of Space Physics, Uppsala, Sweden
  9. Lines: 48
  10.  
  11. In article <ASHERMAN.92Sep9160424@laser.fmrco.com> asherman@fmrco.COM writes:
  12. >
  13. >>>>>> jhd@irfu.se (Jan D.) said:
  14. >
  15. >jhd> chare@unilabs.uucp (Chris Hare) writes:
  16. >
  17. >>As a matter of of fact, if you can suggest a way to remove the leading
  18. >>spaces, and compact multiple spaces any where else on the line to be one
  19. >>space I'd appreciate it.
  20. >>
  21. >
  22. >jhd>     s/^ //;
  23. >jhd>     s/ +/ /g;
  24. >
  25. >jhd> If you want to replace general white space (i.e. tabs and space)
  26. >jhd> you should say:
  27. >
  28. >jhd>     s/^\s//;
  29. >jhd>     s/\s+/ /g;
  30. >
  31. >s/^\s+//;    # or s/^ +//; for just spaces.
  32. >s/\s+/ /g;    # or s/ +//g; for just spaces.
  33. >
  34. >Otherwise:
  35. >
  36. >    "       Hello, world!"
  37. >
  38. >turns into:
  39. >
  40. >    " Hello, world!"
  41. >
  42. >Not:
  43. >
  44. >    "Hello, world!"
  45. >
  46.  
  47. Well, I was looking at Chris first sentence:
  48.  
  49.     I am running 4.035 and I need to delete a single leading space at the
  50.     beginning of a line.
  51.  
  52. And while we are nit picking, your comment for the second
  53. line is wrong :-) :-).
  54.  
  55.     Jan D.
  56.  
  57.  
  58.  
  59.