To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=108273





------- Additional comments from [email protected] Wed Jan 13 14:15:43 +0000 
2010 -------
I'm not so sure this is a defect; it's more an inherent limitation of the
regular expression search, along with misunderstanding of the pattern language.

Because the repetition elements (* or +) are defined as "greedy", searching for
x.*y must look at every character in the paragraph, starting at the first "x",
all the way to the end of the paragraph, then backtrack, looking for a "y" to
end the match.

It's not unreasonable to limit the amount of backtracking that the search will
perform. In Writer, this seems to be around 5850 characters.

The "greedy" repetition is also the reason that the regex in question here
matches multiple quoted passages in the same paragraph: the .* matches _any_
character, /including a closing quote/. So while the pattern may look like it
should match a single quotation, it actually matches everything between the
first open quote and the last closing quote in a paragraph--that could be one
quotation or a hundred.

The greedy behavior and backtracking problem can be avoided by using something
more specific than . (any character): “([^”]*)” I.e., repeat any character
_except_ a close quote, any number of times.

This is foundational for using regexes, which is unfortunate for new users, but
good explanations are easily found, including
http://wiki.services.openoffice.org/wiki/Documentation/How_Tos/Regular_Expressions_in_Writer

I'll attach another test document that has a number of paragraphs, starting with
a quoted word and followed by varying number of characters. The search for
“(.*)” works for all the sample paragraphs, up to 5840 characters after the
quotation, then fails for the last paragraph, with 5850 characters after the
quotation.

---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to