[kde-doc-english] kate and non-greedy regular expressions

Matthew Woehlke mw_triad at users.sourceforge.net
Fri Aug 21 19:28:18 CEST 2009


(Sorry if this multi-posts, it seems to have bounced from k-d-e and I
don't know why it never showed on kwrite-devel... Moderators, if you see 
this, please *reject* the one from the obviously-bogus mail address.)

WK wrote:
> I quote Kate documentation:
> "Greed
> When using quantifiers with no maximum, regular expressions defaults
> to match as much of the searched string as possible, commonly known as
> greedy behavior.
> Modern regular expression software provides the means of “turning off
> greediness”, though in a graphical environment it is up to the
> interface to provide you with access to this feature. For example a
> search dialog providing a regular expression search could have a check
> box labeled “Minimal matching” as well as it ought to indicate if
> greediness is the default behavior."

This feature IIRC is not present in Qt (there was discussion about this
not so long ago on kwrite-devel). Therefore it probably does not make
sense that the documentation should talk about it.

It might be added at some point in the future, but isn't there now.

> I can't find possibility to search non-greedy RE,
> for example i want to get rid of every HTML-tag in some HTML document
> without losing any content. Is this possible in Kate?

You can always search for something that won't match too much, e.g.
'<[^>]+>' will match exactly one SGML tag (not the contents thereof,
however, just the opening tag). I suspect it is not possible without
non-greedy regexp to find e.g. "<p>some <i>text</i></p>", though I think
you can find e.g. "<i>text</i>" for arbitrary tags.

-- 
Matthew
Please do not quote my e-mail address unobfuscated in message bodies.
-- 
Thank you for reading all the way to this .sig. You may stop reading 
now. Really. It is safe to stop. There is no more content. Why are you 
still reading?



More information about the kde-doc-english mailing list