Issue 90025 - Find and Replace: Subexpression fails for some regular expressions
Summary: Find and Replace: Subexpression fails for some regular expressions
Alias: None
Product: Writer
Classification: Application
Component: ui (show other issues)
Version: OOo 2.4.0
Hardware: All Linux, all
: P3 Trivial with 3 votes (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
Depends on:
Reported: 2008-05-27 15:45 UTC by Joe Smith
Modified: 2017-05-20 10:34 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Note You need to log in before you can comment on or make changes to this issue.
Description Joe Smith 2008-05-27 15:45:48 UTC
Reported in comment to Issue 15666; creating new issue for it here.

> I just ran through a few example tasks that people have asked about. I only
> found one glitch:
> Capitalize words beginning with h:
> s/\<h([a-z]+)/
> r/H$1/
> Match case = Yes
> Starting text:   He heard quiet steps behind him.
> Expected result: He Heard quiet steps behind Him.
> Actual result:   He H$1 quiet steps behind H$1

This seems to be related to the beginning-of-word pattern '\<': if I remove
that, the subexpression is replaced as expected.

The problem seems specific to Writer; it works correctly in Calc.
Comment 1 michael.ruess 2008-05-27 16:21:06 UTC
Reassigned to SBA.
Comment 2 stefan.baltzer 2008-06-09 11:47:21 UTC
Confirmed. Reassigned to AMA.
Comment 3 rgb 2008-09-01 11:45:06 UTC
I found the problem with this regular expression:
\<([^ ]+)[ ]+\1\>
I can use it to successfully find duplicated words without "false alarms" like
"he heard". In the text:
He heard the the bell
the expression find "the the", but instead of
He heard the bell
using $1 in "Replace with" gives me
He heard $1 bell
Comment 4 bormant 2009-08-05 19:42:32 UTC
"\>" regular expression pattern in "Search for" blocks "$n" and "&" patterns in 
"Replace with".

For ex., try to add leading zero to #.## numbers:

1) less accurate, search: "\<[0-9]\.[0-9]{2}", replace: "0&" or "0$0"
"1.11" --> "01.11", it's Ok. 

2) more accurate, search: "\<[0-9]\.[0-9]{2}\>", replace: "0&" or "0$0"
"1.11" --> "0&" (or "0$0"), WRONG CASE, replace pattern inserts literally

Calc has no this error, both patterns works as documented.

Tested on OOo-dev 3.2.0 DEV300_m53 Build:9412 on
Comment 5 floris_v 2010-08-28 23:03:40 UTC
Tested in 3.3.0 dev build 9514 and still around.
Comment 6 floris_v 2011-01-20 08:08:25 UTC
Still around in 3.3.0 RC 9.
Comment 7 Joe Smith 2013-09-12 22:14:12 UTC
This issue can be closed: the new regex engine included with AOO 3.4 fixes this problem.