Bug 152511 - REGEXP replace parameters not working
Summary: REGEXP replace parameters not working
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.4.3.2 release
Hardware: All Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-14 20:11 UTC by rajesh
Modified: 2022-12-15 21:03 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description rajesh 2022-12-14 20:11:39 UTC
Description:
Search string is (With Regular Expresson set ON):-
“((\s)|(^))(that)((\s)|([.,!?:;'\"\'-]))”
Replace string is: “$1not$3"

Text is:- 
that this and that this and that ok 

result should be:- 
not this and not this and not ok

but result is:-
notthatthis and notthatthis and notthatok 

Steps to Reproduce:
1.Enter following text in writer: "that this and that this and that ok "
2.In Search & Replace-->Search string is (With Regular Expresson set ON):-
“((\s)|(^))(that)((\s)|([.,!?:;'\"\'-]))”
3.Replace string is: “$1not$3"
4.result should be:- 
"not this and not this and not ok "
5.but result is:-
"notthis and notthis and notok " (using safe mode)

Actual Results:
"notthis and notthis and notok "

Expected Results:
"not this and not this and not ok "


Reproducible: Always


User Profile Reset: No

Additional Info:
This is happening all the time when more than 1 parameter in replace text is used ... e.g. $1$3.
Comment 1 rajesh 2022-12-14 20:14:54 UTC
Result is:  "notthis and notthis and notok " (in safe mode).

Result is: "notthatthis and notthatthis and notthatok " without using safe mode
Comment 2 LeroyG 2022-12-14 21:26:53 UTC
NOT A BUG for me.

The Find string must be: "(\s|^)(that)(\s|[.,!?:;'\"\'-])".

Original text: "that this and that this and that ok "
Result text: "not this and not this and not ok "

Version: 7.3.7.2 (x64) / LibreOffice Community
Build ID: e114eadc50a9ff8d8c8a0567d6da8f454beeb84f
CPU threads: 4; OS: Windows 10.0 Build 19045; UI render: default; VCL: win
Locale: es-MX (es_ES); UI: en-US
Calc: CL
Comment 3 Eike Rathke 2022-12-14 21:56:00 UTC
I could reproduce with LO 7.2.7, but not with LO 7.3.7 nor LO 7.4.4 nor LO 7.5alpha, in all of which the result correctly is
"notthis and that this and that ok "

Note that the capture groups may not be what you think they might be:
group1: ((\s)|(^))
group3: (^)

Anyhow, what platform and LibreOffice version anyway? Please copy-paste the Version Information from the Help -> About LibreOffice dialog.
Comment 4 Eike Rathke 2022-12-14 22:07:43 UTC
Or sorry, out of habit I tried in Calc that does not repeat a match on found strings, actually I can reproduce in Writer even with LO 7.4.4 and using ReplaceAll, but note what is found with a FindAll, all " that ". Anyhow, my capture group remark still is valid.
Comment 5 rajesh 2022-12-15 21:03:27 UTC
Thanks LeroyG for your comment....

"(\s|^)(that)(\s|[.,!?:;'\"\'-])"

does do the trick. 

So this is not a bug! It was my faulty REGEXP.

Thanks again LeroyG

Thank you all for your kindness to reply. I am sorry to have take up your precious time.

I am marking this report as resolved.