home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / perl / 5663 < prev    next >
Encoding:
Internet Message Format  |  1992-09-01  |  1.3 KB

  1. Path: sparky!uunet!usc!news!netlabs!lwall
  2. From: lwall@netlabs.com (Larry Wall)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: String matching with matching delimiters
  5. Message-ID: <1992Sep1.212635.26399@netlabs.com>
  6. Date: 1 Sep 92 21:26:35 GMT
  7. References: <59999@mimsy.umd.edu>
  8. Sender: news@netlabs.com
  9. Distribution: usa
  10. Organization: NetLabs, Inc.
  11. Lines: 21
  12. Nntp-Posting-Host: scalpel.netlabs.com
  13.  
  14. In article <59999@mimsy.umd.edu> folta@cs.umd.edu (Wayne Folta) writes:
  15. : I have been doing a lot of work lately manipulating TeX files with perl. Is
  16. : there an easy way to give a pattern like:
  17. :    /\\hbox{ ... }/
  18. : Where the "..." includes everything up to the *matching* brace. This may
  19. : include closing braces, so "{[^}]+}" does not work. Presently, I loop through
  20. : the string counting opens and closes by hand... I don't think rexegp's are
  21. : powerful enough to do it alone, but in perl...
  22.  
  23. I've considered adding some kind of automatic tokenizing, but for now
  24. you just have to s/// the front off the string and count brackets.  This
  25. is really way beyond the capabilities of regular expressions.
  26.  
  27. : (Also, could rindex be enhanced to be able to match the right-most ocurrence
  28. : *before* a certain point? I.e. to be symmetrical with index.)
  29.  
  30. Already does.  Try supplying a third argument.
  31.  
  32. Larry
  33.