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

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!wupost!darwin.sura.net!uvaarpa!mmdf
  3. From: Dov Grobgeld <dov@menora.weizmann.ac.il>
  4. Subject: Regular expression bug?
  5. Message-ID: <1992Sep13.200457.5806@uvaarpa.Virginia.EDU>
  6. Sender: mmdf@uvaarpa.Virginia.EDU (Mail System)
  7. Reply-To: dov@menora.weizmann.ac.il
  8. Organization: The Internet
  9. Date: Sun, 13 Sep 1992 20:04:57 GMT
  10. Lines: 61
  11.  
  12. I didn't get any replies last time. Perhaps I wasn't clear enough. So
  13. I'll try again.
  14.  
  15. I would like to match a string of the following format:
  16.  
  17.     <n>H<n bytes>
  18.  
  19. where n is a a number in ASCII. Examples of such strings are:
  20.  
  21.      6Horange
  22.      0H
  23.     16Hthis\nis\na string
  24.  
  25. I tried matching them with the following regular expression:
  26.  
  27.     /(\d+)H([\000-\377]{\1})/ &&  print "string= ($2)\n";
  28.  
  29. but it didn't work. The following did work though:
  30.  
  31.     if (s/(\d+)H//) {
  32.         s/([\000-\377]{$1})//;
  33.         print "string= ($1)\n";
  34.     }
  35.  
  36. It seems like you can't give \1,\2,...,\9 inside braces in the same
  37. regular expression. I guess I can live without it. It just means that
  38. I can't use the m//g construct in order to match such strings...
  39. Larry (are you listening?), can this be fixed?
  40.  
  41. By the way, it is quite ugly to have to write [\000-\377] in order to
  42. say "any character". What about providing a hook for redefining "." to
  43. include "\n"?
  44.  
  45. This reminds me of the "\b" construct, which is quite crippled when working
  46. with character sets other than English, since it is impossible in Perl to
  47. redefine what is a letter and what is a white-space. E.g. in Swedish
  48. "ASCII" standard the characters "}", "{", "|" and some others are
  49. used as letters.
  50.  
  51. Certainly the problems won't go away when Perl is ported for Unicode...
  52. What about providing such hooks already now?
  53.  
  54. --
  55.                                                         ___   ___
  56.                                                       /  o  \   o \
  57. Dov Grobgeld                                         ( o  o  ) o   |
  58. The Weizmann Institute of Science, Israel             \  o  /o  o /
  59. "Where the tree of wisdom carries oranges"              | |   | |
  60.                                                        _| |_ _| |_
  61.  
  62.  
  63.  
  64.  
  65. --
  66.                                                         ___   ___
  67.                                                       /  o  \   o \
  68. Dov Grobgeld                                         ( o  o  ) o   |
  69. The Weizmann Institute of Science, Israel             \  o  /o  o /
  70. "Where the tree of wisdom carries oranges"              | |   | |
  71.                                                        _| |_ _| |_
  72.                                        
  73.