[cl-ppcre-devel] Weird :START Behaviour in CL-PPCRE:SCAN

Chris Dean ctdean at sokitomi.com
Thu Jul 5 23:31:04 UTC 2007


>   (cl-ppcre:scan
>    "^\\[([^ ]{1,})+[ ]*(.{1,})?\\]"
>    "foo [[Main]] [http://baz]''bold'''''''bar''''"
>    :start 13)

This is a regular expression that does lots of backtracking when it
fails.  If you change that you'll most likely see a large performance
improvement.

A small change is to simplify the first grouping:

   "^\\[([^ ]{1,})[ ]*(.{1,})?\\]" 

The reason that having :start is so much slower is that the regex
matches a different string that needs far less backtracking that
without the :start.

Cheers,
Chris Dean



More information about the Cl-ppcre-devel mailing list