Pattern matching » History » Version 2
Version 1 (digitalcircuit, 09/13/2018 03:29 AM) → Version 2/13 (digitalcircuit, 09/13/2018 03:51 AM)
h1. Pattern matching
*WORK IN PROGRESS*
{{toc}}
h2. Upgrade notice
*This changed in Quassel @0.13@. "Follow the migration guide":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Migrating-from-versions-prior-to-013 if you're upgrading from an earlier version.*
When using the client and core with different versions, some ignore rules will be processed differently.
h2. Breakdown of usage
Quassel supports several types of pattern matching for ignore and highlight rules.
h3. Ignore Rules
|_. @Regular expression@ |_. Item |_. Pattern matching type |
| Unchecked | @Ignore Rule@ | "Wildcard":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Wildcard |
| Unchecked | @Scope@ | "Multiple wildcard":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Multiple-wildcard |
| Checked | @Ignore Rule@ | "Regular expression":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Regular-expression |
| Checked | @Scope@ | "Multiple wildcard":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Multiple-wildcard |
_For backwards compatibility, the @Regular expression@ checkbox only affects @Ignore Rule@ and not @Scope@._
h3. Highlight Rules
|_. @RegEx@ |_. Item |_. Pattern matching type |
| Unchecked | @Rule@ | "Phrase":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Phrase "Phrase":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Wildcard |
| Unchecked | @Sender@ | "Multiple wildcard":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Multiple-wildcard |
| Unchecked | @Channel@ | "Multiple wildcard":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Multiple-wildcard |
| Checked | @Rule@ | "Regular expression":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Regular-expression |
| Checked | @Sender@ | "Regular expression":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Regular-expression |
| Checked | @Channel@ | "Regular expression":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Regular-expression |
_This applies to both @Local Highlights@ and @Remote Highlights@ (or if using Monolithic, @Legacy Highlights@ and @Highlights@)._
h2. Types
h3. Phrase
This matches exactly what you type.
<pre>
word
</pre>
* Matches
** @word@
** @A word.@
** @has a word in it@
* Does not match
** @wording@
_Changed in Quassel @0.13@:_
Spaces are matched, too, allowing you to be more specific.
<pre>
spaced
</pre>
_There's a leading space in the example above._
* Matches
** @, spaced@
** @is spaced out@
* Does not match
** @;spaced@
"Return to breakdown of usage":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching/edit#Breakdown-of-usage
h3. Wildcard
_Changed in Quassel @0.13@:_
This uses simple wildcard substitution with @*@ and @?@ to match any characters or a single character, respectively. The backslash character @\@ allows matching a literal @*@, @?@, or @\@.
<pre>
*Asking questions\? Nope?
</pre>
* Matches
** @Asking questions? Nopea@
** @Basking questions? Nope.@
* Does not match
** @Asking questions. Nope.@
** @Asking questions? Nopes.@
Implicit wildcard is supported, too, allowing you to match everything *except* for what you specify.
<pre>
!*filter*
</pre>
* Matches
** _Everything, unless it contains something from the below list_
* Does not match
** @filter@
** @filtering@
** @#nofilter yo@
Exclamation points can be escaped at the beginning to match something that starts with @!@ (_this is not required elsewhere_).
<pre>
\!*filter*
</pre>
* Matches
** @!filter@
** @!yes filtering@
* Does not match
** @filter@
The @\@ character can be escaped, too, in case you're matching something that starts with @\!@.
<pre>
\\!*filter*
</pre>
* Matches
** @\!filter@
** @\!yes filtering@
* Does not match
** @filter@
** @!filter@
"Return to breakdown of usage":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching/edit#Breakdown-of-usage
h3. Multiple wildcard
This allows matching multiple "wildcard patterns":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching/edit#Wildcard all in one rule by separating each wildcard with semicolons @;@.
<pre>
alpha; beta*
</pre>
* Matches
** @alpha@
** @betas@
** @beta!@
* Does not match
** @alphamore@
** @nonbeta@
_Changed in Quassel @0.13@:_
More complex wildcard patterns are possible. Use @\@ to escape special characters.
<pre>
Alice!*; Bob!*@example.com; Carol*!*; !Caroline!*
Dan!*; escaped \; separator; \!not-inverted; \\!slash-prefixed
</pre>
_For ignore rule @Scope@, you can use @;@ and line breaks interchangeably._
* Matches
** @Alice![...]@
** @Bob![...]@example.com@
** @Carol[...]![...]@ except as noted below
** @Dan![...]@
** @escaped ; separator@
** @!not-inverted@
** @\!slash-prefixed@
* Does not match
** @Caroline![...]@
** @Malice![...]
** @John!@
Implicit wildcard is supported, too, allowing you to match everything *except* for what you specify.
<pre>
!Announce*!*; !Wheatley!aperture@*
</pre>
* Matches
** _Everything, unless it contains something from the below list_
* Does not match
** @Announce[...]![...]@
** @Wheatley!aperture@[...]@
"Return to breakdown of usage":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching/edit#Breakdown-of-usage
h3. Regular expression
This matches using the full regular expression language, best for complex rules and those already familiar with how regular expressions work. Quassel offers a non-standard @!@ prefix to invert the rule; if not desired, escape as @\!@.
The web provides many resources for testing and verifying regular expressions, including https://regex101.com/ .
Some differences exist from Perl due to design choices and limitations of the Qt framework. These are documented on the Qt documentation site for "QRegularExpression":https://doc.qt.io/qt-5/qregularexpression.html#unsupported-perl-compatible-regular-expressions-features with Qt 5, and "QRegExp":https://doc.qt.io/qt-5/qregexp.html#notes-for-perl-users for Qt 4. If you're not sure, you're likely using a Qt 5 build.
<pre>
simple.\*escape-match.*
</pre>
* Matches
** @simpleA*escape-match@
** @simpleA*escape-matchBBBB@
* Does not match
** @not above@
** @simpleA*escape-mat@
** @simple*escape-match@
** @simpleABBBBescape-matchBBBB@
Inverted rules are supported, allowing you to match everything *except* for what you specify.
<pre>
!invert.\*escape-match.*
</pre>
* Matches
** _Everything, unless it contains something from the below list_
* Does not match
** @invertA*escape-match@
** @invertA*escape-matchBBBB@
_Changed in Quassel @0.13@:_
Exclamation points can be escaped at the beginning to match something that starts with @!@ (_this is not required elsewhere_).
<pre>
\!simple.\*escape-match.*
</pre>
* Matches
** @!simpleA*escape-matchBBBB@
* Does not match
** @simpleA*escape-matchBBBB@
The @\@ character can be escaped, too, in case you're matching something that starts with @\!@.
<pre>
\\!simple.\*escape-match.*
</pre>
* Matches
** @\!simpleA*escape-matchBBBB@
* Does not match
** @!simpleA*escape-matchBBBB@
"Return to breakdown of usage":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching/edit#Breakdown-of-usage TODO
h2. Migrating from versions prior to @0.13@
Quassel @0.13@ introduced new behavior for pattern matching to provide more flexibility and to improve performance.
h3. Ignore Rules
h3. Highlight Rules
h2. Technical details
For all the technical details and source code changes, take a look at "Quassel pull request #415":https://github.com/quassel/quassel/pull/415 . @MultiPhrase@ is not covered here as Quassel only uses it internally for nickname matching.
*WORK IN PROGRESS*
{{toc}}
h2. Upgrade notice
*This changed in Quassel @0.13@. "Follow the migration guide":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Migrating-from-versions-prior-to-013 if you're upgrading from an earlier version.*
When using the client and core with different versions, some ignore rules will be processed differently.
h2. Breakdown of usage
Quassel supports several types of pattern matching for ignore and highlight rules.
h3. Ignore Rules
|_. @Regular expression@ |_. Item |_. Pattern matching type |
| Unchecked | @Ignore Rule@ | "Wildcard":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Wildcard |
| Unchecked | @Scope@ | "Multiple wildcard":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Multiple-wildcard |
| Checked | @Ignore Rule@ | "Regular expression":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Regular-expression |
| Checked | @Scope@ | "Multiple wildcard":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Multiple-wildcard |
_For backwards compatibility, the @Regular expression@ checkbox only affects @Ignore Rule@ and not @Scope@._
h3. Highlight Rules
|_. @RegEx@ |_. Item |_. Pattern matching type |
| Unchecked | @Rule@ | "Phrase":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Phrase "Phrase":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Wildcard |
| Unchecked | @Sender@ | "Multiple wildcard":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Multiple-wildcard |
| Unchecked | @Channel@ | "Multiple wildcard":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Multiple-wildcard |
| Checked | @Rule@ | "Regular expression":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Regular-expression |
| Checked | @Sender@ | "Regular expression":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Regular-expression |
| Checked | @Channel@ | "Regular expression":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Regular-expression |
_This applies to both @Local Highlights@ and @Remote Highlights@ (or if using Monolithic, @Legacy Highlights@ and @Highlights@)._
h2. Types
h3. Phrase
This matches exactly what you type.
<pre>
word
</pre>
* Matches
** @word@
** @A word.@
** @has a word in it@
* Does not match
** @wording@
_Changed in Quassel @0.13@:_
Spaces are matched, too, allowing you to be more specific.
<pre>
spaced
</pre>
_There's a leading space in the example above._
* Matches
** @, spaced@
** @is spaced out@
* Does not match
** @;spaced@
"Return to breakdown of usage":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching/edit#Breakdown-of-usage
h3. Wildcard
_Changed in Quassel @0.13@:_
This uses simple wildcard substitution with @*@ and @?@ to match any characters or a single character, respectively. The backslash character @\@ allows matching a literal @*@, @?@, or @\@.
<pre>
*Asking questions\? Nope?
</pre>
* Matches
** @Asking questions? Nopea@
** @Basking questions? Nope.@
* Does not match
** @Asking questions. Nope.@
** @Asking questions? Nopes.@
Implicit wildcard is supported, too, allowing you to match everything *except* for what you specify.
<pre>
!*filter*
</pre>
* Matches
** _Everything, unless it contains something from the below list_
* Does not match
** @filter@
** @filtering@
** @#nofilter yo@
Exclamation points can be escaped at the beginning to match something that starts with @!@ (_this is not required elsewhere_).
<pre>
\!*filter*
</pre>
* Matches
** @!filter@
** @!yes filtering@
* Does not match
** @filter@
The @\@ character can be escaped, too, in case you're matching something that starts with @\!@.
<pre>
\\!*filter*
</pre>
* Matches
** @\!filter@
** @\!yes filtering@
* Does not match
** @filter@
** @!filter@
"Return to breakdown of usage":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching/edit#Breakdown-of-usage
h3. Multiple wildcard
This allows matching multiple "wildcard patterns":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching/edit#Wildcard all in one rule by separating each wildcard with semicolons @;@.
<pre>
alpha; beta*
</pre>
* Matches
** @alpha@
** @betas@
** @beta!@
* Does not match
** @alphamore@
** @nonbeta@
_Changed in Quassel @0.13@:_
More complex wildcard patterns are possible. Use @\@ to escape special characters.
<pre>
Alice!*; Bob!*@example.com; Carol*!*; !Caroline!*
Dan!*; escaped \; separator; \!not-inverted; \\!slash-prefixed
</pre>
_For ignore rule @Scope@, you can use @;@ and line breaks interchangeably._
* Matches
** @Alice![...]@
** @Bob![...]@example.com@
** @Carol[...]![...]@ except as noted below
** @Dan![...]@
** @escaped ; separator@
** @!not-inverted@
** @\!slash-prefixed@
* Does not match
** @Caroline![...]@
** @Malice![...]
** @John!@
Implicit wildcard is supported, too, allowing you to match everything *except* for what you specify.
<pre>
!Announce*!*; !Wheatley!aperture@*
</pre>
* Matches
** _Everything, unless it contains something from the below list_
* Does not match
** @Announce[...]![...]@
** @Wheatley!aperture@[...]@
"Return to breakdown of usage":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching/edit#Breakdown-of-usage
h3. Regular expression
This matches using the full regular expression language, best for complex rules and those already familiar with how regular expressions work. Quassel offers a non-standard @!@ prefix to invert the rule; if not desired, escape as @\!@.
The web provides many resources for testing and verifying regular expressions, including https://regex101.com/ .
Some differences exist from Perl due to design choices and limitations of the Qt framework. These are documented on the Qt documentation site for "QRegularExpression":https://doc.qt.io/qt-5/qregularexpression.html#unsupported-perl-compatible-regular-expressions-features with Qt 5, and "QRegExp":https://doc.qt.io/qt-5/qregexp.html#notes-for-perl-users for Qt 4. If you're not sure, you're likely using a Qt 5 build.
<pre>
simple.\*escape-match.*
</pre>
* Matches
** @simpleA*escape-match@
** @simpleA*escape-matchBBBB@
* Does not match
** @not above@
** @simpleA*escape-mat@
** @simple*escape-match@
** @simpleABBBBescape-matchBBBB@
Inverted rules are supported, allowing you to match everything *except* for what you specify.
<pre>
!invert.\*escape-match.*
</pre>
* Matches
** _Everything, unless it contains something from the below list_
* Does not match
** @invertA*escape-match@
** @invertA*escape-matchBBBB@
_Changed in Quassel @0.13@:_
Exclamation points can be escaped at the beginning to match something that starts with @!@ (_this is not required elsewhere_).
<pre>
\!simple.\*escape-match.*
</pre>
* Matches
** @!simpleA*escape-matchBBBB@
* Does not match
** @simpleA*escape-matchBBBB@
The @\@ character can be escaped, too, in case you're matching something that starts with @\!@.
<pre>
\\!simple.\*escape-match.*
</pre>
* Matches
** @\!simpleA*escape-matchBBBB@
* Does not match
** @!simpleA*escape-matchBBBB@
"Return to breakdown of usage":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching/edit#Breakdown-of-usage TODO
h2. Migrating from versions prior to @0.13@
Quassel @0.13@ introduced new behavior for pattern matching to provide more flexibility and to improve performance.
h3. Ignore Rules
h3. Highlight Rules
h2. Technical details
For all the technical details and source code changes, take a look at "Quassel pull request #415":https://github.com/quassel/quassel/pull/415 . @MultiPhrase@ is not covered here as Quassel only uses it internally for nickname matching.