[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Stack overflow in regexp matcher
From: |
Dan Davison |
Subject: |
Stack overflow in regexp matcher |
Date: |
Sun, 06 Feb 2011 10:47:42 +0000 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (darwin) |
The following fails with "Stack overflow in regexp matcher" in emacs 23
and 24:
(string-match
"^\\[.+\\]$"
(concat
"["
(mapconcat (lambda (i) "x") (number-sequence 1 33500) "")
"]"))
This surprised me; I assumed that the ^ and $ anchors, and the simple
".+" requirement in the middle would result in a simple, efficient
regexp.
In this case I can replace this with a different test using `substring',
but I'm curious: was the above obviously unwise to someone who knows
about emacs regexps? What would be a better regexp be to use in this
sutuation? Fwiw, The same match seems to work instantaneously in
e.g. perl.
Dan
- Stack overflow in regexp matcher,
Dan Davison <=