replace with regular expression problem


#1

hi,

I have a work-around for this, but I don't understand what the problem really is, and why I have solved it. Can anyone teach me?

1- What is being "falsely recognized" in the (.*) case?
2- Why does [^] start of a line anchor solve the problem?


Problem:

title: 01 - Love's a Precious Thing One Strange Sunday

using replace with regular expression

field: title
regular expression: (.*)
replace match with: junk $1

Produces: junk 01 - Love's a Precious Thing One Strange Sundayjunk

(The problem is the trailing added "junk")

Solution: use start of line anchor [^]

field: title
regular expression: ^(.*)
replace match with: junk $1

Produces:
junk 01 - Love's a Precious Thing One Strange Sunday


!!! end of line anchor [$] didn't work

field: title
regular expression: (.*)$
replace match with: junk $1

Produces:
Produces: junk 01 - Love's a Precious Thing One Strange Sundayjunk
with the trailing added "junk"

I don't understand why front anchor works, as the "bad" replace is at the end of line & supposedly "." matches everything EXCEPT new line
I thought there must be a false recog & replace of the new line character.


#2

Other testcases:

title: TestTitle
using replace with regular expression
field: TITLE
regular expression: .*
replace match with: junk $0
Produces: junk TestTitlejunk

For me it looks and feels like a bug.

title: TestTitle
using replace with regular expression
field: TITLE
regular expression: .+
replace match with: junk $0
Produces: junk TestTitle

This solves the problem in the case that there exists minimal one character in the TITLE tag.

DD.20061001.0754