# Why this (otherwise working) regular expression doesn't work in expl3 (lookbehind syntax)?

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

\documentclass[margin=5mm,varwidth]{standalone}
\usepackage{expl3}
\begin{document}
\ExplSyntaxOn
% must match dot that precedes "d"
\regex_match:nnTF{(?<=d)\.}{hello world.this is. some test}{match}{NO~match}
\ExplSyntaxOff
\end{document}

• 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
• you get a warning from your code. Nov 17, 2019 at 20:09
• @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
• Look ahead/behind are not strictly regular, and at an implementation level, Bruno decided that the speed impact would be non-trivial Nov 17, 2019 at 21:11
• @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

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.

• Comments are not for extended discussion; this conversation has been moved to chat. Dec 4, 2019 at 7:54