Issue 118925 - ICU Regex: look-ahead and look-behind are not work well with replacement
Summary: ICU Regex: look-ahead and look-behind are not work well with replacement
Status: CLOSED FIXED
Alias: None
Product: Writer
Classification: Application
Component: code (show other issues)
Version: 3.4.0
Hardware: All All
: P3 Normal (vote)
Target Milestone: 3.4.1
Assignee: hdu@apache.org
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-16 15:21 UTC by hanya
Modified: 2012-06-26 08:05 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---
jsc: 3.4.1_release_blocker+


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description hanya 2012-02-16 15:21:44 UTC
On revision 1240836 from unofficial dev build.

Text: abcdef

Search for: ab(?=c)
Replace with: -$0-
This look-ahead matches "ab" for search but replacement results "-$0-cdef"

Next look-behind example does not match anymore.
Search for: (?<=b)c
This should be match with "c" but recent build does not match with it. With Python's re module, it matches "c".
Comment 1 hdu@apache.org 2012-03-16 15:55:19 UTC
Thanks for the report. The regression described in the report's second issue is now fixed with revision 1301596.

The first problem described in the report has its root cause somewhere in Writer where for some reason Writer checks itself whether the found string is really a match. This seems to fail; probably because Writer doesn't understand the advanced constructs of the new engine like look-ahead/look-behind yet. I think the easiest solution would be simply having WriterEngine trust the findings of the regexp engine. Changing things in that critical area are too risky for now.
Comment 2 hdu@apache.org 2012-03-19 15:22:54 UTC
FWIW: a code pointer to the first issue would be ReplaceBackReferences() in
main/sw/source/ui/uiview/viewsrch.cxx
Comment 3 hdu@apache.org 2012-03-19 16:04:04 UTC
(In reply to comment #2)
> in main/sw/source/ui/uiview/viewsrch.cxx

Correction, the function is in: main/sw/source/core/crsr/findtxt.cxx
Comment 4 hdu@apache.org 2012-05-09 14:06:18 UTC
With rev 1336210 I added support to make group-references in the replacement string work for look-ahead/look-behind regexp contexts.
Comment 5 hdu@apache.org 2012-05-30 06:59:34 UTC
Requesting the 3.4.1 flag for this issue: Writer should keep up with the features of the regexp engine that has become much more powerful with AOO 3.4.0. Otherwise the asymmetry between the Find and the Replacement functionality would be too confusing.
Comment 6 jsc 2012-05-31 07:18:44 UTC
set release blocker flag for 3.4.1

we exchanged the regex engine for 3.4 and this fix will improve/finalize the replacmeent
Comment 7 hdu@apache.org 2012-06-06 14:54:48 UTC
Also applied into AOO34 branch as 1346922.
Comment 8 Terry Yang 2012-06-26 06:39:51 UTC
Verify fixed on AOO 3.4 Branch Dev snapshot rev.1351960 and AOO Trunk Rev. 1351712

Suggest close this bug
Comment 9 hdu@apache.org 2012-06-26 08:05:57 UTC
Thanks for verifying on trunk and release branch! Closing the resolved bug.