Project

General

Profile

Pattern matching » History » Version 3

« Previous - Version 3/13 (diff) - Next » - Current version
digitalcircuit, 09/13/2018 03:52 AM
Fix return links


Pattern matching

WORK IN PROGRESS

Upgrade notice

This changed in Quassel 0.13. Follow the migration guide if you're upgrading from an earlier version.

When using the client and core with different versions, some ignore rules will be processed differently.

Breakdown of usage

Quassel supports several types of pattern matching for ignore and highlight rules.

Ignore Rules

Regular expression Item Pattern matching type
Unchecked Ignore Rule Wildcard
Unchecked Scope Multiple wildcard
Checked Ignore Rule Regular expression
Checked Scope Multiple wildcard

For backwards compatibility, the Regular expression checkbox only affects Ignore Rule and not Scope.

Highlight Rules

RegEx Item Pattern matching type
Unchecked Rule Phrase
Unchecked Sender Multiple wildcard
Unchecked Channel Multiple wildcard
Checked Rule Regular expression
Checked Sender Regular expression
Checked Channel Regular expression

This applies to both Local Highlights and Remote Highlights (or if using Monolithic, Legacy Highlights and Highlights).

Types

Phrase

This matches exactly what you type.

word
  • 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.

 spaced

There's a leading space in the example above.

  • Matches
    • , spaced
    • is spaced out
  • Does not match
    • ;spaced

Return to breakdown of usage

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

*Asking questions\?  Nope?
  • 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.

!*filter*
  • 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).

\!*filter*
  • Matches
    • !filter
    • !yes filtering
  • Does not match
    • filter

The \ character can be escaped, too, in case you're matching something that starts with \!.

\\!*filter*
  • Matches
    • \!filter
    • \!yes filtering
  • Does not match
    • filter
    • !filter

Return to breakdown of usage

Multiple wildcard

This allows matching multiple wildcard patterns all in one rule by separating each wildcard with semicolons ;.

alpha; beta*
  • 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.

Alice!*; Bob!*@example.com; Carol*!*; !Caroline!*
Dan!*; escaped \; separator; \!not-inverted; \\!slash-prefixed

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.

!Announce*!*; !Wheatley!aperture@*
  • Matches
    • Everything, unless it contains something from the below list
  • Does not match
    • Announce[...]![...]
    • Wheatley!aperture[...]@

Return to breakdown of usage

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 with Qt 5, and QRegExp for Qt 4. If you're not sure, you're likely using a Qt 5 build.

simple.\*escape-match.*
  • 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.

!invert.\*escape-match.*
  • 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).

\!simple.\*escape-match.*
  • 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 \!.

\\!simple.\*escape-match.*
  • Matches
    • \!simpleA*escape-matchBBBB
  • Does not match
    • !simpleA*escape-matchBBBB

Return to breakdown of usage

Migrating from versions prior to 0.13

Quassel 0.13 introduced new behavior for pattern matching to provide more flexibility and to improve performance.

Ignore Rules

Highlight Rules

Technical details

For all the technical details and source code changes, take a look at Quassel pull request #415 . MultiPhrase is not covered here as Quassel only uses it internally for nickname matching.