Agent Ransack includes a regular
expression engine as one of its Expression Types. Regular expressions (some times shortened to
regexp) provide a concise language to describe exactly what to search for. In
very basic terms you can split an expression into two parts:
- what you are looking for
- the number of occurrences you want
to find of it.
So let's take an example:
1. I want to find all files named
abc, abbc, abbbc, abbbbc etc. So basically I want to find all files that
begin with 'a' followed by one or more 'b' then followed by 'c'. The
expression would be:
ab+c
Breaking that apart we read:
- find one occurrence of 'a'
- find at least one occurrence of 'b'
(the '+' indicates 'one or more')
- find one occurrence of 'c'
The characters that specify the
number of occurrences are:
+ one or more
* zero or more
? zero or one
So ab?c would find any file named abc
or ac (i.e. there can be zero or one 'b').
A very important regexp character is
the period '.' (the wildcard character) because it matches to ANY character.
So a.c would match to aac, abc, acc, adc, aec, afc, a1c, a6c etc. And if we
combine that with an occurrence character we can start producing some useful
expressions:
dave.*vest
breaks down to:
- find one occurrence of 'd'
- then one occurrence of 'a'
- then one occurrence of 'v'
- then one occurrence of 'e'
- then zero or more occurrences of
ANY character
- then one occurrence of 'v'
- then one occurrence of 'e'
- then one occurrence of 's'
- then one occurrence of 't'
and so matches to 'davevest', 'dave
vest', 'dave is wearing a vest'.
There are other regexp characters and
tricks on the following pages. More detail on regular expressions.
|