Description: When using a search and replace string such as this one: (\s+)([—|–]|\-{1,})(\s*)(.*?)(\s*)([—|–]|\-{1,}) and replace the results with –$4– any emphasis or italics (ith happens both when italics/emphasis is the only formatting and when it is just a word which is in italics/emphasis) is gone and one finds a text in with the regular format instead. Steps to Reproduce: 1. Create or upload the attached document with - word italicsword word -. 2. Use Regex (\s+)([—|–]|\-{1,})(\s*)(.*?)(\s*)([—|–]|\-{1,}) to find the instance. 3. Replace with –$4– Actual Results: Italics/emphasis is gone Expected Results: Italics and emphasis should remain since I do not want to change them. Reproducible: Always User Profile Reset: No Additional Info: If it is not a bug and meant to be working like this, maybe a "keep format" option could be added to the search and replace window since the change which occurs is not desired by the user. It does happen with other search and replace strings (quotes for example) (\s+)([—|“]|\-{1,})(\s*)(.*?)(\s*)([—|”]|\-{1,})
Created attachment 167564 [details] Test case This file has a number of instances which can be used to test what the bug states.
from https://bugs.documentfoundation.org/show_bug.cgi?id=62603#c15 > Regex is irrelevant - it happens without regex as well. Basically, Find/Replace > applies the format of the first character across the entire replaced string. But yes, I understand that you are pulling the "replace" out of your search string, so perhaps their could be a bit more intelligence built-in to also carry along the current formatting. But I fully expect that this just gets a string of text, and not a fragment of fully formatted Writer text. *** This bug has been marked as a duplicate of bug 62603 ***