home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!mcsun!sunic!corax.udac.uu.se!irfu.se!jhd
- From: jhd@irfu.se (Jan D.)
- Subject: Re: stupid questions : deleted ing leading spaces
- Message-ID: <1992Sep10.225848.3307@irfu.se>
- Date: Thu, 10 Sep 1992 22:58:48 GMT
- References: <1992Sep7.022351.1137@unilabs.uucp> <1992Sep7.062649.20540@irfu.se> <ASHERMAN.92Sep9160424@laser.fmrco.com>
- Organization: Swedish Institute of Space Physics, Uppsala, Sweden
- Lines: 48
-
- In article <ASHERMAN.92Sep9160424@laser.fmrco.com> asherman@fmrco.COM writes:
- >
- >>>>>> jhd@irfu.se (Jan D.) said:
- >
- >jhd> chare@unilabs.uucp (Chris Hare) writes:
- >
- >>As a matter of of fact, if you can suggest a way to remove the leading
- >>spaces, and compact multiple spaces any where else on the line to be one
- >>space I'd appreciate it.
- >>
- >
- >jhd> s/^ //;
- >jhd> s/ +/ /g;
- >
- >jhd> If you want to replace general white space (i.e. tabs and space)
- >jhd> you should say:
- >
- >jhd> s/^\s//;
- >jhd> s/\s+/ /g;
- >
- >s/^\s+//; # or s/^ +//; for just spaces.
- >s/\s+/ /g; # or s/ +//g; for just spaces.
- >
- >Otherwise:
- >
- > " Hello, world!"
- >
- >turns into:
- >
- > " Hello, world!"
- >
- >Not:
- >
- > "Hello, world!"
- >
-
- Well, I was looking at Chris first sentence:
-
- I am running 4.035 and I need to delete a single leading space at the
- beginning of a line.
-
- And while we are nit picking, your comment for the second
- line is wrong :-) :-).
-
- Jan D.
-
-
-
-