Tcl versions: 8.4.16, 8.5b1.
macosx 10.4.9
Normally, "^" matches the start of input:
% regexp -line -start 0 {^foo} "foo"
1
When -line is specified, "^" matches the beginning of a line in
the middle of the input:
% regexp -line -start 0 {^foo} "\nfoo"
1
When -start is used, "^" will not match the text at the -start
location:
% regexp -line -start 1 {^foo} "\nfoo"
0
However, "\A" will match there just fine:
% regexp -line -start 1 {\Afoo} "\nfoo"
1
I think the third case is a bug; all four of these examples should match.
Logged In: YES
user_id=75003
Originator: NO
Note that the behaviour of the third case is, IIRC, documentend as such ... Yes, regexp.n ...
-start index
Specifies a character index offset into the string to start matching the regular expression at.
When using this switch, `^' will not match the beginning of the line, and \A will still match
the start of the string at index.
Logged In: YES
user_id=75003
Originator: NO
Forgot to say, I know this because I fell into the same trap first and had to rewrite ^ to \A in code of mine where I wanted to use -start to avoid 'string range' and shifting the string down.
Logged In: YES
user_id=372859
Originator: YES
This is a duplicate of bug 471101.