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

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!uvaarpa!mmdf
  3. From: Dov Grobgeld <dov@menora.weizmann.ac.il>
  4. Subject: Regexp bug/feature?
  5. Message-ID: <1992Sep7.092154.3578@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: Mon, 7 Sep 1992 09:21:54 GMT
  10. Lines: 43
  11.  
  12. I have as input, strings of a type called HOLLERITH which are given
  13. by the length as an integer in ASCII characters, followed by "H" followed
  14. by the string. Examples of such strings are "3Haaa", "16Hthis\nis\na string".
  15.  
  16. I tried matching them with the following regular expression:
  17.  
  18.     if (s/(\d+)H([\000-\377]{\1})//) {
  19.         print "string= ($2)\n";
  20.     }
  21.  
  22. but it didn't work. The following did work though:
  23.  
  24.     if (s/(\d+)H//) {
  25.         s/([\000-\377]{$1})//;
  26.         print "string= ($1)\n";
  27.     }
  28.  
  29. It seems like you can't give \1,\2,...,\9 inside braces in the same
  30. regular expression. I guess I can live without it. It just means that
  31. I can't use the m//g construct in order to match such strings...
  32. Larry, can this be fixed?
  33.  
  34. By the way, it is quite ugly to have to write [\000-\377] in order to
  35. say "any character". What about providing a hook for redefining "." to
  36. include "\n"?
  37.  
  38. This reminds me of the "\b" construct, which is quite crippled when working
  39. with character sets other than English, since it is impossible in Perl to
  40. redefine what is a letter and what is a white-space. E.g. in Swedish
  41. "ASCII" standard the characters "}", "{", "|" and some others are
  42. used as letters.
  43.  
  44. Certainly the problems won't go away when Perl is ported for Unicode...
  45. What about providing such hooks already now?
  46.  
  47. --
  48.                                                         ___   ___
  49.                                                       /  o  \   o \
  50. Dov Grobgeld                                         ( o  o  ) o   |
  51. The Weizmann Institute of Science, Israel             \  o  /o  o /
  52. "Where the tree of wisdom carries oranges"              | |   | |
  53.                                                        _| |_ _| |_
  54.                                        
  55.