Previous: , Up: Regular Expressions   [Contents][Index]

35.3.5 Problems with Regular Expressions

The Emacs regexp implementation, like many of its kind, is generally robust but occasionally causes trouble in either of two ways: matching may run out of internal stack space and signal an error, and it can take a long time to complete. The advice below will make these symptoms less likely and help alleviate problems that do arise.

If you run into regexp stack overflow despite following the above advice, don’t be afraid of performing the matching in multiple function calls, each using a simpler regexp where backtracking can more easily be contained.

Function: re--describe-compiled regexp &optional raw

To help diagnose problems in your regexps or in the regexp engine itself, this function returns a string describing the compiled form of regexp. To make sense of it, it can be necessary to read at least the description of the re_opcode_t type in the src/regex-emacs.c file in Emacs’s source code.

It is currently able to give a meaningful description only if Emacs was compiled with --enable-checking.

Previous: Regular Expression Functions, Up: Regular Expressions   [Contents][Index]