Apache OpenOffice (AOO) Bugzilla – Issue 75214
Writer - regex "[\t|\n]+" does not find neither tab, nor end of paragraph
Last modified: 2007-03-08 17:01:37 UTC
Searching for "[\t|\n]+" does not find tab, space, or end of paragraph (EoP). Repro steps: 1. Open Writer, random text including "t", press tab and Enter (to enter end of paragraph character). 2. Press Ctrl-F to open S&R dialog, click "More Options" and check "Regular Expression". 3. Enter "[\t|\n]+" (no quotes) in "Search for" and click Find. Note how "t"'s are found, but not tabs or EoP.
(Corrected summary)
Reassigned to SBA.
SBA: The string inside the square brackets, is "treated differently". In this case it is NOT interpreted as regular expression. A good example (see list of regular expressions) is the "^": "[^a-s]" finds any character that is not between a and s. "^a-s" finds the string "a-s" when it is at the beginnig of a paragraph. In your case, the \n and \t INSIDE the brackets are NOT interpreted as hard line break but as "find the letters n and t". Clarification: For Search Strings: \n = "New Line" = A hard Line break, entered with <Shift>+>Enter>. With "nonprinting characters visible", it looks like a tiny broken arrow, just like the one on the "Enter" Key on regular Computer Keyboards. $ = "Paragraph End", entered with <Enter>. With "nonprinting characters visible", it looks like a "mirrored P" with two vertical lines. For replace strings: \n in "Replace Feld" adds a Paragraph break. I admit that this is not very intuiitive. This is good old (OK, very old) code. I know that the regular expression handling already triggerd a nice pile of enhancement or feature requests. A search for "Regular Ex" OR Regex" AND "State= NOT closed" brings up 30 results (Defects, enhancements and features). Most of them have target OOo Later, thus developers from the community shall feel free very welcome to make things better in this area. I regard issue 46165 as a good "survivor" for the problem with combining regular expressions. I put the findings here into that one and put kpalagin on c/c of that one. Set to duplicate. *** This issue has been marked as a duplicate of 46165 ***
SBA: Closed.