Project

General

Profile

Pattern matching » History » Version 2

digitalcircuit, 09/13/2018 03:51 AM
Finish the general matching types

1 1 digitalcircuit
h1. Pattern matching
2 1 digitalcircuit
3 1 digitalcircuit
*WORK IN PROGRESS*
4 1 digitalcircuit
5 1 digitalcircuit
{{toc}}
6 1 digitalcircuit
7 1 digitalcircuit
h2. Upgrade notice
8 1 digitalcircuit
9 1 digitalcircuit
*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.*
10 1 digitalcircuit
11 1 digitalcircuit
When using the client and core with different versions, some ignore rules will be processed differently.
12 1 digitalcircuit
13 1 digitalcircuit
h2. Breakdown of usage
14 1 digitalcircuit
15 1 digitalcircuit
Quassel supports several types of pattern matching for ignore and highlight rules.
16 1 digitalcircuit
17 1 digitalcircuit
h3. Ignore Rules
18 1 digitalcircuit
19 1 digitalcircuit
|_. @Regular expression@ |_. Item |_. Pattern matching type |
20 1 digitalcircuit
| Unchecked | @Ignore Rule@ | "Wildcard":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Wildcard |
21 1 digitalcircuit
| Unchecked | @Scope@ | "Multiple wildcard":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Multiple-wildcard |
22 1 digitalcircuit
| Checked | @Ignore Rule@ | "Regular expression":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Regular-expression |
23 1 digitalcircuit
| Checked | @Scope@ | "Multiple wildcard":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Multiple-wildcard |
24 1 digitalcircuit
25 1 digitalcircuit
_For backwards compatibility, the @Regular expression@ checkbox only affects @Ignore Rule@ and not @Scope@._
26 1 digitalcircuit
27 1 digitalcircuit
h3. Highlight Rules
28 1 digitalcircuit
29 1 digitalcircuit
|_. @RegEx@ |_. Item |_. Pattern matching type |
30 2 digitalcircuit
| Unchecked | @Rule@ | "Phrase":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Phrase |
31 1 digitalcircuit
| Unchecked | @Sender@ | "Multiple wildcard":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Multiple-wildcard |
32 1 digitalcircuit
| Unchecked | @Channel@ | "Multiple wildcard":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Multiple-wildcard |
33 1 digitalcircuit
| Checked | @Rule@ | "Regular expression":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Regular-expression |
34 1 digitalcircuit
| Checked | @Sender@ | "Regular expression":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Regular-expression |
35 1 digitalcircuit
| Checked | @Channel@ | "Regular expression":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching#Regular-expression |
36 1 digitalcircuit
37 1 digitalcircuit
_This applies to both @Local Highlights@ and @Remote Highlights@ (or if using Monolithic, @Legacy Highlights@ and @Highlights@)._
38 1 digitalcircuit
39 1 digitalcircuit
h2. Types
40 1 digitalcircuit
41 1 digitalcircuit
h3. Phrase
42 1 digitalcircuit
43 1 digitalcircuit
This matches exactly what you type.
44 1 digitalcircuit
45 1 digitalcircuit
<pre>
46 1 digitalcircuit
word
47 1 digitalcircuit
</pre>
48 1 digitalcircuit
49 1 digitalcircuit
* Matches
50 1 digitalcircuit
** @word@
51 1 digitalcircuit
** @A word.@
52 1 digitalcircuit
** @has a word in it@ 
53 1 digitalcircuit
* Does not match
54 1 digitalcircuit
** @wording@
55 1 digitalcircuit
56 1 digitalcircuit
_Changed in Quassel @0.13@:_
57 1 digitalcircuit
58 1 digitalcircuit
Spaces are matched, too, allowing you to be more specific.
59 1 digitalcircuit
60 1 digitalcircuit
<pre>
61 1 digitalcircuit
 spaced
62 1 digitalcircuit
</pre>
63 1 digitalcircuit
64 1 digitalcircuit
_There's a leading space in the example above._
65 1 digitalcircuit
66 1 digitalcircuit
* Matches
67 1 digitalcircuit
** @, spaced@
68 1 digitalcircuit
** @is spaced out@
69 1 digitalcircuit
* Does not match
70 1 digitalcircuit
** @;spaced@
71 1 digitalcircuit
72 2 digitalcircuit
"Return to breakdown of usage":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching/edit#Breakdown-of-usage
73 2 digitalcircuit
74 1 digitalcircuit
h3. Wildcard
75 1 digitalcircuit
76 1 digitalcircuit
_Changed in Quassel @0.13@:_
77 1 digitalcircuit
78 2 digitalcircuit
This uses simple wildcard substitution with @*@ and @?@ to match any characters or a single character, respectively.  The backslash character @\@ allows matching a literal @*@, @?@, or @\@.
79 1 digitalcircuit
80 1 digitalcircuit
<pre>
81 1 digitalcircuit
*Asking questions\?  Nope?
82 1 digitalcircuit
</pre>
83 1 digitalcircuit
84 1 digitalcircuit
* Matches
85 1 digitalcircuit
** @Asking questions? Nopea@
86 1 digitalcircuit
** @Basking questions? Nope.@
87 1 digitalcircuit
* Does not match
88 1 digitalcircuit
** @Asking questions. Nope.@
89 1 digitalcircuit
** @Asking questions? Nopes.@
90 1 digitalcircuit
91 1 digitalcircuit
Implicit wildcard is supported, too, allowing you to match everything *except* for what you specify.
92 1 digitalcircuit
93 1 digitalcircuit
<pre>
94 1 digitalcircuit
!*filter*
95 1 digitalcircuit
</pre>
96 1 digitalcircuit
97 1 digitalcircuit
* Matches
98 1 digitalcircuit
** _Everything, unless it contains something from the below list_
99 1 digitalcircuit
* Does not match
100 1 digitalcircuit
** @filter@
101 1 digitalcircuit
** @filtering@
102 1 digitalcircuit
** @#nofilter yo@
103 1 digitalcircuit
104 1 digitalcircuit
Exclamation points can be escaped at the beginning to match something that starts with @!@ (_this is not required elsewhere_).
105 1 digitalcircuit
106 1 digitalcircuit
<pre>
107 1 digitalcircuit
\!*filter*
108 1 digitalcircuit
</pre>
109 1 digitalcircuit
110 1 digitalcircuit
* Matches
111 1 digitalcircuit
** @!filter@
112 1 digitalcircuit
** @!yes filtering@
113 1 digitalcircuit
* Does not match
114 1 digitalcircuit
** @filter@
115 1 digitalcircuit
116 1 digitalcircuit
The @\@ character can be escaped, too, in case you're matching something that starts with @\!@.
117 1 digitalcircuit
118 1 digitalcircuit
<pre>
119 1 digitalcircuit
\\!*filter*
120 1 digitalcircuit
</pre>
121 1 digitalcircuit
122 1 digitalcircuit
* Matches
123 1 digitalcircuit
** @\!filter@
124 1 digitalcircuit
** @\!yes filtering@
125 1 digitalcircuit
* Does not match
126 1 digitalcircuit
** @filter@
127 1 digitalcircuit
** @!filter@
128 1 digitalcircuit
129 2 digitalcircuit
"Return to breakdown of usage":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching/edit#Breakdown-of-usage
130 2 digitalcircuit
131 1 digitalcircuit
h3. Multiple wildcard
132 1 digitalcircuit
133 2 digitalcircuit
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 @;@.
134 2 digitalcircuit
135 2 digitalcircuit
<pre>
136 2 digitalcircuit
alpha; beta*
137 2 digitalcircuit
</pre>
138 2 digitalcircuit
139 2 digitalcircuit
* Matches
140 2 digitalcircuit
** @alpha@
141 2 digitalcircuit
** @betas@
142 2 digitalcircuit
** @beta!@
143 2 digitalcircuit
* Does not match
144 2 digitalcircuit
** @alphamore@
145 2 digitalcircuit
** @nonbeta@
146 2 digitalcircuit
147 2 digitalcircuit
_Changed in Quassel @0.13@:_
148 2 digitalcircuit
149 2 digitalcircuit
More complex wildcard patterns are possible.  Use @\@ to escape special characters.
150 2 digitalcircuit
151 2 digitalcircuit
<pre>
152 2 digitalcircuit
Alice!*; Bob!*@example.com; Carol*!*; !Caroline!*
153 2 digitalcircuit
Dan!*; escaped \; separator; \!not-inverted; \\!slash-prefixed
154 2 digitalcircuit
</pre>
155 2 digitalcircuit
156 2 digitalcircuit
_For ignore rule @Scope@, you can use @;@ and line breaks interchangeably._
157 2 digitalcircuit
158 2 digitalcircuit
* Matches
159 2 digitalcircuit
** @Alice![...]@
160 2 digitalcircuit
** @Bob![...]@example.com@
161 2 digitalcircuit
** @Carol[...]![...]@ except as noted below
162 2 digitalcircuit
** @Dan![...]@
163 2 digitalcircuit
** @escaped ; separator@
164 2 digitalcircuit
** @!not-inverted@
165 2 digitalcircuit
** @\!slash-prefixed@
166 2 digitalcircuit
* Does not match
167 2 digitalcircuit
** @Caroline![...]@
168 2 digitalcircuit
** @Malice![...]
169 2 digitalcircuit
** @John!@
170 2 digitalcircuit
171 2 digitalcircuit
Implicit wildcard is supported, too, allowing you to match everything *except* for what you specify.
172 2 digitalcircuit
173 2 digitalcircuit
<pre>
174 2 digitalcircuit
!Announce*!*; !Wheatley!aperture@*
175 2 digitalcircuit
</pre>
176 2 digitalcircuit
177 2 digitalcircuit
* Matches
178 2 digitalcircuit
** _Everything, unless it contains something from the below list_
179 2 digitalcircuit
* Does not match
180 2 digitalcircuit
** @Announce[...]![...]@
181 2 digitalcircuit
** @Wheatley!aperture@[...]@
182 2 digitalcircuit
183 2 digitalcircuit
"Return to breakdown of usage":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching/edit#Breakdown-of-usage
184 2 digitalcircuit
185 1 digitalcircuit
h3. Regular expression
186 1 digitalcircuit
187 2 digitalcircuit
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 @\!@.
188 2 digitalcircuit
189 2 digitalcircuit
The web provides many resources for testing and verifying regular expressions, including https://regex101.com/ .
190 2 digitalcircuit
191 2 digitalcircuit
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.
192 2 digitalcircuit
193 2 digitalcircuit
<pre>
194 2 digitalcircuit
simple.\*escape-match.*
195 2 digitalcircuit
</pre>
196 2 digitalcircuit
197 2 digitalcircuit
* Matches
198 2 digitalcircuit
** @simpleA*escape-match@
199 2 digitalcircuit
** @simpleA*escape-matchBBBB@
200 2 digitalcircuit
* Does not match
201 2 digitalcircuit
** @not above@
202 2 digitalcircuit
** @simpleA*escape-mat@
203 2 digitalcircuit
** @simple*escape-match@
204 2 digitalcircuit
** @simpleABBBBescape-matchBBBB@
205 2 digitalcircuit
206 2 digitalcircuit
Inverted rules are supported, allowing you to match everything *except* for what you specify.
207 2 digitalcircuit
208 2 digitalcircuit
<pre>
209 2 digitalcircuit
!invert.\*escape-match.*
210 2 digitalcircuit
</pre>
211 2 digitalcircuit
212 2 digitalcircuit
* Matches
213 2 digitalcircuit
** _Everything, unless it contains something from the below list_
214 2 digitalcircuit
* Does not match
215 2 digitalcircuit
** @invertA*escape-match@
216 2 digitalcircuit
** @invertA*escape-matchBBBB@
217 2 digitalcircuit
218 2 digitalcircuit
_Changed in Quassel @0.13@:_
219 2 digitalcircuit
220 2 digitalcircuit
Exclamation points can be escaped at the beginning to match something that starts with @!@ (_this is not required elsewhere_).
221 2 digitalcircuit
222 2 digitalcircuit
<pre>
223 2 digitalcircuit
\!simple.\*escape-match.*
224 2 digitalcircuit
</pre>
225 2 digitalcircuit
226 2 digitalcircuit
* Matches
227 2 digitalcircuit
** @!simpleA*escape-matchBBBB@
228 2 digitalcircuit
* Does not match
229 2 digitalcircuit
** @simpleA*escape-matchBBBB@
230 2 digitalcircuit
231 2 digitalcircuit
The @\@ character can be escaped, too, in case you're matching something that starts with @\!@.
232 2 digitalcircuit
233 2 digitalcircuit
<pre>
234 2 digitalcircuit
\\!simple.\*escape-match.*
235 2 digitalcircuit
</pre>
236 2 digitalcircuit
237 2 digitalcircuit
* Matches
238 2 digitalcircuit
** @\!simpleA*escape-matchBBBB@
239 2 digitalcircuit
* Does not match
240 2 digitalcircuit
** @!simpleA*escape-matchBBBB@
241 2 digitalcircuit
242 2 digitalcircuit
"Return to breakdown of usage":https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Pattern_matching/edit#Breakdown-of-usage
243 1 digitalcircuit
244 1 digitalcircuit
h2. Migrating from versions prior to @0.13@
245 1 digitalcircuit
246 1 digitalcircuit
Quassel @0.13@ introduced new behavior for pattern matching to provide more flexibility and to improve performance.
247 1 digitalcircuit
248 1 digitalcircuit
h3. Ignore Rules
249 1 digitalcircuit
250 1 digitalcircuit
251 1 digitalcircuit
h3. Highlight Rules
252 1 digitalcircuit
253 1 digitalcircuit
h2. Technical details
254 1 digitalcircuit
255 1 digitalcircuit
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.