Ticket #746 (closed defect: wontfix)
regex replace all is overeager
| Reported by: | daxim | Owned by: | zenogantner |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | editor | Version: | 0.50 |
| Keywords: | Cc: |
Description
- Paste the following content into a new document.
authors/id/A/AB/ABIGAIL/Algorithm-Numerical-Sample-2009102701.tar.gz ... updated authors/id/A/AB/ABIGAIL/CHECKSUMS ... updated authors/id/A/AB/ABIGAIL/Date-Maya-2009102701.tar.gz ... updated authors/id/A/AG/AGROLMS/LWP-Authen-Negotiate-0.07.tar.gz ... updated authors/id/A/AG/AGROLMS/CHECKSUMS ... updated authors/id/A/AZ/AZAWAWI/Acme-CPANAuthors-Padre-0.02.tar.gz ... updated authors/id/A/AZ/AZAWAWI/CHECKSUMS ... updated authors/id/B/BE/BERLE/DBIx-Class-Tree-CalculateSets-0.03.tar.gz ... updated authors/id/B/BE/BERLE/CHECKSUMS ... updated authors/id/B/BO/BOBTFISH/Text-Markdown-1.000028.tar.gz ... updated authors/id/B/BO/BOBTFISH/CHECKSUMS ... updated
- Search → Replace
- Enter into »Find Text:« \s+.*$
- Check »Regular Expression» and »Replace All«
- Confirm »Replace«
Expected result
Leaves the following transformed text:
authors/id/A/AB/ABIGAIL/Algorithm-Numerical-Sample-2009102701.tar.gz authors/id/A/AB/ABIGAIL/CHECKSUMS authors/id/A/AB/ABIGAIL/Date-Maya-2009102701.tar.gz authors/id/A/AG/AGROLMS/LWP-Authen-Negotiate-0.07.tar.gz authors/id/A/AG/AGROLMS/CHECKSUMS authors/id/A/AZ/AZAWAWI/Acme-CPANAuthors-Padre-0.02.tar.gz authors/id/A/AZ/AZAWAWI/CHECKSUMS authors/id/B/BE/BERLE/DBIx-Class-Tree-CalculateSets-0.03.tar.gz authors/id/B/BE/BERLE/CHECKSUMS authors/id/B/BO/BOBTFISH/Text-Markdown-1.000028.tar.gz authors/id/B/BO/BOBTFISH/CHECKSUMS
Actual result
Leaves the following transformed text:
authors/id/A/AB/ABIGAIL/Algorithm-Numerical-Sample-2009102701.tar.gz
Change History
comment:1 Changed 3 years ago by zenogantner
- Owner set to zenogantner
- Status changed from new to accepted
comment:2 Changed 3 years ago by zenogantner
- Status changed from accepted to closed
- Resolution set to wontfix
The regular expression that is searched for is (?mi-xs:\s+.*$), which means that
- the text is treated as a multi-line text, i.e. "$" means "just before end of the line"
- matching is case insensitive (not relevant here)
- not an extended regular expression
- do not treat text as single line, i.e. "." means "any character except newline"
Let's dissect the regex:
\s+ will match any sequence of whitespace characters in the text (also the newlines)
\s+.*$ will then match as above plus anything that comes along until we reach the end of a line.
So we first match
... updated
and then match
(newline) authors/id/A/AB/ABIGAIL/CHECKSUMS ... updated
and so on.
Which is correct: newline is also a whitespace character.
To get the results you want, you could use this regex instead: [ \t]+.*$
I would say this is not a bug, but rather unexpected (but correct) behavior.
I am closing this ticket, feel free to re-open and/or leave comments.

I can reproduce this.