[Libreoffice-bugs] [Bug 137737] REPLACE not working if there is a footnote or endnote anchor at end of paragraph

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Thu Aug 26 06:43:42 UTC 2021


https://bugs.documentfoundation.org/show_bug.cgi?id=137737

--- Comment #15 from Mike Kaganski <mikekaganski at hotmail.com> ---
(In reply to Justin L from comment #14)
> I don't think ^ specifically means "beginning of paragraph" in every
> context. I would expect it to be the beginning of the search string. So if
> only a selection of text was chosen, it would refer to the beginning of the
> selection (and if the selection contained multiple lines[aka paragraphs], it
> would also match the beginning of these other lines).

No. It must match start of the paragraph to behave according to least surprise
principle.

The caret is a special kind of a look-behind assertion, and as such, it needs
to consider the data *to the left* of current position. Consider a look-behind
condition like

  (?<=\s).

It must only succeed if the previous character was a "space". Then in a text
like

  lorem ipsum

when you select only the second word "ipsum", and use "current selection only",
you would have the "i" *matching* the regex. If you would not consider the text
outside of the selection as the context, you would not be able to match the
starting character, or you would need to select the character before this.
(Yes, there are ways to create more sophisticated queries, but they would
likely be less specific - e.g., using ^ as alternative in (?<=^|\s) would also
match starts of paragraphs in selections spanning over paragraph boundaries,
which is likely not what user wanted.)

Regex engines also have this idea, expressed in e.g. icu::RegexMatcher::region
[1] allowing to search inside a specific region, but considering the data
outside of it as the context (configurable though).

[1]
https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1RegexMatcher.html#a556e40af5e725121ad23944b24e0fb1b

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20210826/cce56b6c/attachment.htm>


More information about the Libreoffice-bugs mailing list