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

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!newshost!root
  3. From: mmelling@Trirex.com(Michael Mellinger)
  4. Subject: Parsing RTF
  5. Message-ID: <1992Sep15.035214.13097@Trirex.COM>
  6. Sender: root@Trirex.COM (Operator)
  7. Organization: Trirex Systems Inc.
  8. Date: Tue, 15 Sep 1992 03:52:14 GMT
  9. Lines: 23
  10.  
  11. I'm interested in writing a small RTF parser in Perl.  Given rtf text,  
  12. like that shown below, what is the best way to extract tokens from the  
  13. text?
  14.  
  15. {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
  16. \margl120
  17. \margr120
  18. {{\attachment0 telephonedirectory2.wp
  19. }
  20. \pard\tx533\tx1067\tx1601\tx2135\tx2668\tx3202\tx3736\tx4270\tx4803\tx5337 
  21. \f0\b0\i0\ul0\fs36 This is the body of the message.
  22.  
  23. The keywords like \rtf and tx (tab settings) are followed by numbers, and  
  24. as can be seen, keywords don't need to be seperated by spaces.   At the  
  25. moment, I just want to extract out the keywords, but later I anticipate  
  26. wanting to do more.
  27.  
  28. For those that don't know anything about RTF(Rich Text Format), all  
  29. keywords begin with a \ and groups of keywords(like stylesheets) are  
  30. enclose in {}.
  31.  
  32. -Mike
  33. mmelling@Trirex.com
  34.