Note: The mainteinance of the scripting examples is discontinued since I no longer have an interest to continue doing so. The pages will remain here, for now, but that might not be the case in the future. You are free to download all the material on these pages and set a up mirror, or even continue the maintenance of the material by enhancing the examples yourself.

All the material in these examples are for the mIRC version 6.03. It is very likely that some or most of these examples won't work in future versions.

Understanding wildcards

Most of the remote events accept wildcards in the event definition field. Wildcards are a simple tool for matching text. When a string is compared with a wildcard string the result is always either true or false. There are more powerful methods for matching text, like regular exmpressions, but wildcards are often faster and easier. Naturally they have their limits and when the task is complex enough, I recommend moving to regular expressions.

mIRC recognizes three wildcard characterss.

The definitions are often precise and clear but hard to understand without examples. Here are examples of each wildcard character used to match text. The parts of the wildcard string that cause the match to fail are highlighted.

Asterisk

*a* matches we were a good couple
*t* does not match we were a good couple
*good* matches we were a good couple
*bad* does not match we were a good couple
*were a good* matches we were a good couple
*were a very good* does not match we were a good couple
*good couple matches we were a good couple
*good does not match we were a good couple
we * matches we were a good couple
were * does not match we were a good couple
we*couple matches we were a good couple
were*couple does not match we were a good couple

Question mark

a matches ?
a does not match ???
ab does not match ?
abc matches ???
abc matches a?c
abc 123 matches abc ???
abc 123 does not match abc 4??

Ampersand

& matches apple
& does not match big apple
& apple matches big apple
!guess & does not match !guess
!guess & matches !guess scissors
!guess & does not match !guess scissors stone
& & & matches one two three

Combining the wildcards

The wildcards can be combined freely. There are a few useful methods I suggest you to learn. If you wish something to be at least 3 characters without upper bound, you can use '???*'. If you wish to check that the string has at least two words, you can use '& *'. In real situations the question mark and ampersand are used rarely. The question mark is really are. The ampersand is useful when you need to check that the number of parameters for a trigger is right, for example when you wanted to listen '!op <nick>' using '!op &' would be a good idea. Another application for ampersand are the raw numerics you get from the server. The parameters are usually separated with a space so using ampersand as a wildcard is a good idea. Neverthless asterisk is the most common wildcard without any doubt.

The most common asterisk wildcard patterns


Last updated 2003-04-05, Janne 'Geetee' Nikula, jn-mirc@zkelvin.net