Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How can one use \pdfmatch with regular expressions and where can one find a listing and description of all the available pdfTeX primitives and help on their use?

Edit

The latest issue of the pdfTeX documentation, now contains a small description with examples for the command.

share|improve this question
2  
Unfortunately, many of the pdftex primitives are not properly documented. The pdftex source code seems to be the only definitive reference. –  Lev Bishop Oct 20 '10 at 18:05
    
@Lev Bishop Thanks for your quick response. –  Yiannis Lazarides Oct 20 '10 at 18:14
    
See patch 375: <sarovar.org/tracker/…;. –  Martin Heller Oct 20 '10 at 19:10
    
@Yiannis: The documentation of Heiko Oberbiek's askinclude package has a section on how to use \pdfmatch. I have not yet studied this and the source code of pdftex, but I will when I get time. –  Bruno Le Floch Jan 3 '11 at 21:30
1  
groups.google.com/group/comp.text.tex/browse_thread/thread/… --- and --- groups.google.com/group/comp.text.tex/browse_thread/thread/… --- have extra pointers (Heiko Oberdiek in both cases). Sorry don't know how to make links in comments. –  Bruno Le Floch Jan 4 '11 at 22:30
show 2 more comments

2 Answers 2

up vote 12 down vote accepted

See pdftex 1.30.0 announcement, in particular:

  - \pdfmatch [icase] [subcount <number>}] {<pattern>}{<string>}
    Implements pattern matching using the POSIX regex.
    It returns the same values as \pdfstrcmp, but with the following
    semantics: 
      -1: error case (invalid pattern, ...)
       0: no match
       1: match found
    Options:
    * icase: case insensitive matching
    * subcount: it sets the table size for found subpatterns.
      A number "-1" resets the table size to the start default.
  - \pdflastmatch <number>
    The result of \pdfmatch is stored in an array. The entry "0" contains
    the match, the following entries submatches. The positions of the
    matches are also available. They are encoded:
      <position> "->" <match string>
    The position "-1" with an empty string indicates that this entry is not
    set.
share|improve this answer
add comment

For regular expressions specifically, the l3regex package provides a cross-engine solution (needs eTeX and \strcmp).

For instance,

\RequirePackage{l3regex}
\ExplSyntaxOn
\regex_extract_all:nnN { \w+ } { Hello,~ world! } \l_foo_seq
\seq_show:N \l_foo_seq

shows Hello and world as the two items of the resulting sequence (list).

Here's a list of various questions of whose one answer uses l3regex

share|improve this answer
    
Admittedly, this is shameless self-promotion. But the l3regex package was partially written because there is no consistent engine support for regular expressions, so that is on topic here. –  Bruno Le Floch Oct 22 '11 at 5:42
    
I saw it the other day, looks good, don't you want to give a rather longer example? –  Yiannis Lazarides Oct 22 '11 at 7:04
1  
@Yiannis: I'll try to think of better examples (those I put in the doc are rather pointless, since I don't know which applications would be typical :)). I gave a longer example (showing only the replacement feature) in answer to a question about removing dots depending on surrounding characters. –  Bruno Le Floch Oct 22 '11 at 8:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.