Either expl3 doesn't support lookbehind or I'm doing something wrong.

    % must match dot that precedes "d"
    \regex_match:nnTF{(?<=d)\.}{hello world.this is. some test}{match}{NO~match}
  • 7
    Page 233 of interface3.tex (at the end of the l3regex part) says: "The following features are likely to be implemented at some point in the future: • General look-ahead/behind assertions." So I suppose it's not possible yet. You can open an issue/feature request in the LaTeX3 repo for this to be implemented. Nov 17, 2019 at 20:09
  • 3
    you get a warning from your code. Nov 17, 2019 at 20:09
  • 5
    @bp2017 I'd not call it a disappointment, rather too much work for too few people. l3regex alone is more than 3000 lines of code and was written mostly by Bruno, so I believe that what is not yet implemented is due to the amount of effort vs. the number of use cases. Should you have an use case and present it, I think that you stand better chances of having this implemented... Nov 17, 2019 at 21:04
  • 5
    Look ahead/behind are not strictly regular, and at an implementation level, Bruno decided that the speed impact would be non-trivial
    – Joseph Wright
    Nov 17, 2019 at 21:11
  • 1
    @bp2017 you don't even need to look in the log it is a warning not a info message, it is printed on the terminal as well as the log file. Nov 18, 2019 at 1:05

1 Answer 1


The LaTeX3 regex engine covers a documented set of features. In particular, look-behind is not currently implemented. The l3regex implementation uses a finite state automata, and it is possible to implement look around: see https://cs.stackexchange.com/questions/2557/how-to-simulate-backreferences-lookaheads-and-lookbehinds-in-finite-state-auto. However, the work is tricky and has not to-date been tackled.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .