To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=46015
                  Issue #:|46015
                  Summary:|RegEx: Allow less greedy regular expressions
                Component:|framework
                  Version:|OOo 2.0 Beta
                 Platform:|All
                      URL:|
               OS/Version:|All
                   Status:|UNCONFIRMED
        Status whiteboard:|
                 Keywords:|
               Resolution:|
               Issue type:|ENHANCEMENT
                 Priority:|P4
             Subcomponent:|ui
              Assigned to:|tm
              Reported by:|erpel





------- Additional comments from [EMAIL PROTECTED] Fri Mar 25 09:02:41 -0800 
2005 -------
At the moment, regular expressions in OOo are always greedy. It would be nice 
to 
be able to make them a bit less greedy... :-) (In other regexs, this is often 
implemented by a Question Mark.)

In combination with issue 15666, the Search-And-Replace with regular 
expressions 
would be much more powerful.

For more information about the greediness of regexs, look at section 5.2 (para 
"And Quantifier Again") of:
http://www.regenechsen.de/regex_en/regex_3_en.html


<Quote>
Ok, now let's move on to some special behaviour relating to quantifiers, Some 
of 
them have a 'human' peculiarity: they are greedy! You don't believe that? Well, 
look at the following string <g>:

"The abbreviation 'ISP' stands for 'Internet Service Provider'."

We want a regex that finds the text that is enclosed by inverted commas and 
stores it in a subpattern:

"(.*)'(.*)'.*"

Nothing difficult really: find everything that comes before an inverted comma, 
then everything in between and finally everything that followsâ

And? Did you try it on the regex-tester? What is in subpattern 2? "Internet 
Service Provider". Ooops, I expected "ISP" because it comes first in the 
string. 
:-o It is quite obvious that the first group (.*) greedily matched most of the 
string and left only what was at least necessary for subpattern 2 to match the 
whole string. Furthermore, the last element ".*" in the regex allowed 'nothing' 
or void to follow. Keeping this in mind: this part leads to a successful match 
even if nothing is to be matched. The star stands for as many appearances as 
there are or none at all!

[...]

Conclusion: Alter the Regex to "(.*?)'(.*?)'.*".
</Quote>

---------------------------------------------------------------------
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