Searching with Wildcards

Numeric vs. String Fields

Some fields in log entries are treated as numeric values and others as character strings. The numeric fields are: "Date", "Time", "Frequency", "Power", and "Zone". All other fields are treated as string fields.

Numeric and string fields have unique features for their search keys. Numeric field search keys allow you to search for a range of values. String field search keys can contain "wildcards" that allow flexible pattern matching.

String Field Search Keys - Using Wildcards

Search keys using wildcards consist of two parts, a comparison and a value to compare against. A simple wildcard for the Name field could use = as the comparison and a value of john* to match names that start with john. The * is a special wildcard character that matches any number of characters in the field.

Here are a few variations:

john No comparison, matches john exactly
=john Matches john exactly
=john* Matches fields starting with john
=*john Matches fields ending with john
=*john* Matches fields containing john anywhere

Here's a list of all the wildcard characters available for string fields.

* Matches multiple characters
? Match any single character
?? Match any two characters
etc.

# Match one numeric character
## Match two numeric characters
etc.

[a-z] Match a through z or A through Z
[a-c] Match a through c or A through C
[0-5] Match 0 though 5
etc.

Examples:

=? Match fields containing only one character
=abc? Match 4 character fields starting abc
=abc?? Match 5 character fields starting abc
=abc* Match fields starting abc
=a*bc Match fields: a, anything, bc
=*abc* Match fields containing abc
=a*#bc Match fields: a, anything, number, bc
=[a-b]*[y-z] Match fields starting a to b and ending y to z

String Field Search Keys - Using ~

As noted above you can use a search key of the form =*abc* to match fields that contain the string abc anywhere within the field. You can also use the equivalent form ~abc to save a bit of typing.

Example:

~abc Match fields containing abc

String Field Search Keys - Comparisons

All the examples so far have used = as the comparison. Here's a complete list of comparisons:

= Equal
> Greater than
>= Greater than or equal
< Less than
<= Less than or equal

Although comparisons like less than and greater than are normally used with numeric fields they can also be used with string fields, for example:

>=p* - Match fields starting p, q, r, s, ...

String Field Search Keys - The "Not" Character

Preceding the comparison with a ! will reverse the sense of the match - i.e. the key specifies what not to match.

Examples:

!=abc Match any fields but abc
!=*abc Match fields except those ending abc
!=[a-z] Match one character fields except a to z
!=*[a-z] Match fields except those ending a to z
!=*[0-9]* Match fields containing no numbers

String Field Search Keys - Matching Null Fields

The search keys described so far consist of a comparison followed by a value. However there are two special search keys used to select fields with no value set or fields with any value set.

= Match null fields
!= Match non-null fields

Null field matching can be useful when checking QSL status. For example, to select entries for Brazil having outstanding QSLs use:

Country: PY
QSL Sent: !=
QSL Rcvd: =

String Field Search Keys - Final Notes

Remember that search keys using wildcards/ranges must start with a comparison otherwise XMLog will look for fields that exactly match the search key. But what do you do if you want to search for something that starts with a comparison character? If you enclose the entire key in quotes then no character in the key will be treated as a comparison or wildcard character. For example, to exactly match =abc use the search key "=abc".

There are times when you want to match a wildcard character exactly rather than treat it as a wildcard. For instance if you wanted to search for all QSOs with deleted countries you would need at to supply a prefix search key that matches anything starting with *. Using =** would not do the trick, you need a way to say "don't treat the first * as a wildcard character". Enclosing a single character within [] means that the character won't be considered a wildcard character. So our search key would become =[*]*

Examples:

=[*]* Match fields starting with *
=[[]abc[]]* Match fields starting with [abc]

Numeric Field Search Keys - Using Ranges

Search keys for numeric fields can't contain wildcard characters (*, ?, # and [x-y]), but comparisons can be provided to narrow a search to a range of values.

All the comparisons available for string fields are also available for numeric fields. For example:

1230 No range, match 1230 exactly
=1230 Match 1230 exactly
>1230 Match values greater than 1230

Multiple comparisons can be given by separating them with commas or semicolons. Using a comma specifies a logical "and" - all the comparisons must be true for a match. Using a semicolon specifies a logical "or" - only one of the comparisons needs to be true for a match.

>=0,<=1230 Match 0 through 1230
>=0,<=1230,!=1200 Match 0 through 1230 but not 1200
>=1/1/88,<=1/31/88 Match dates in Jan 1988
=1;=5;>7 Match 1 or 5 or greater than 7
<1/1/88;>1/31/88 Match dates not in Jan 1988

Note the difference between using "and" and "or". A search key of >=1,<=2 would match numbers one through two, >=1;<=2 would match any number.

Preceding the comparison with a ! will reverse the sense of the match - i.e. the key specifies what not to match.

!=22 - Match anything except 22
!>22 - Not greater, same as <=22