home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / perl / 7772 < prev    next >
Encoding:
Internet Message Format  |  1993-01-12  |  885 b 

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!howland.reston.ans.net!spool.mu.edu!hri.com!enterpoop.mit.edu!eru.mt.luth.se!lunic!sunic!aun.uninett.no!nuug!symbas!hans
  2. From: hans@symbas.UUCP (Hans Aafloy)
  3. Newsgroups: comp.lang.perl
  4. Subject: pattern matching
  5. Message-ID: <3730@symbas.UUCP>
  6. Date: 12 Jan 93 17:48:59 GMT
  7. Reply-To: hans@symlab.UUCP ()
  8. Organization: Symbiotic Computer Systems A/S, Trondheim, Norway
  9. Lines: 15
  10.  
  11. I expexted the constructs    /\d{1,1}/  or /\d{1}/
  12. to match single digits only, but it seems to match multiple digit
  13. numbers as well.
  14. My problem is trivial, and I know a couple of ways to get around
  15. it, but since I'll use Perl a lot in the future, I want to get to
  16. the bottom of things like this.
  17.  
  18. I simply want to insert a leading zero in front of a one digit date:
  19. s/ *(\d{1})/0$1/;
  20. and it replaces 88 with 088 as well as 8 with 08.
  21.  
  22.  
  23. Thanx for any hints.
  24.  
  25. Hans
  26.