|
2007-11-21
| ||
| 03:10 | • Closed ticket [1835348fff]: Regex "^" doesn't match start of text ... artifact: c49bd154f6 user: duquette | |
| 03:00 | • Ticket [1835348fff]: 4 changes artifact: a49695dc93 user: andreas_kupries | |
| 02:57 | • Ticket [1835348fff]: 4 changes artifact: 41c504301c user: andreas_kupries | |
|
2007-11-20
| ||
| 19:35 | • New ticket [1835348fff]. artifact: dce24c22cd user: duquette | |
Regex "^" doesn't match start of text when -start is used
Closed / Duplicate1835348fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2007-11-20 19:35:15
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.
andreas_kupriesplain2007-11-21 02:57:32
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.
andreas_kupriesplain2007-11-21 03:00:11
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.
duquetteplain2007-11-21 03:10:31
Logged In: YES user_id=372859 Originator: YES This is a duplicate of bug 471101.
Log in (anonymous is fine) to add a comment.