Search start position at position elisp regexp
I am doing some parsing in elisp and I have a string that I am partially consuming (let's say its value is "foobar123"
). Suppose I have used "foobar"
(so I know I need to start parsing from char 6) and I expect to use 2
.
I have tried the following and none of them do what I want.
(string-match "2" "foobar123" 6) ; Matches the `2` at character 7.
(string-match "^2" "foobar23" 6) ; Not at the beginning of line.
(string-match "\\`2" "foobar23" 6) ; Not at the beginning of string.
I managed to pull out the substring and match it (i.e. (string-match "^2" (substring "foobar23" 6))
), but that seems wasteful. It seems to me that I need a special character that means "match at start of search", but I cannot find it. Is there a better way?
+3
source to share