Regular expressions {GCDkit}R Documentation

Implementation of regular expressions in GCDkit

Description

Implementation of regular expressions in the searching patterns.

Details

Many enquiries in the GCDkit employ regular expressions. This is a quite powerful searching mechanism more familiar to people working in Unix. Put in simple terms, most characters, including all letters and digits, are regular expressions that match themselves. However, metacharacters with a special meaning ('?' '+' '{' '}' '|' '(' ')') must be preceded by a backslash.

Regular expression Matches
. Any character
^ Beginning of the expression
\$ End of the expression
[ ] Any of the characters given in square brackets
[m-n] Any character in the range given by m and n

A subexpression is a regular expression enclosed in '\(' and '\)'. Two such subexpressions may be joined by the infix operator '|' (logical or); the resulting regular expression matches any string matching either of them. For instance:

\(South\)|\(North\)Uist

yields both

South Uist and North Uist.

A regular expression may be followed by one of several repetition operators:

Repetition operator The preceding item will be matched
? At most once (i.e. is optional)
* Zero or more times
+ One or more times
{n} Exactly n times
{n,} At least n times
{n,m} At least n times, but not more than m times

Author(s)

Vojtech Janousek, vojtech.janousek@geology.cz

See Also

regex

Examples

## Not run: 
# Subset by label
The searched field corresponds to localities with the following levels: 
Mull, Rum, Skye, Coll, Colonsay, Hoy, Westray, Sanday, 
Stronsay, Tiree, Islay

Search pattern = ol       
Coll, Colonsay

Search pattern = n.a      
Colonsay, Sanday, Stronsay

Search pattern = ^S       
Skye, Sanday, Stronsay

Search pattern = e$       
Skye, Tiree

Search pattern = [ds]ay   
Colonsay, Sanday, Stronsay

Search pattern = [p-s]ay
Colonsay, Westray, Stronsay

Search pattern = ol|oy    
Coll, Colonsay, Hoy

Search pattern = l{2}   
Mull, Coll


# Subset by sample name
The sample names are: Bl-1, Bl-3, Koz-1, Koz-2, Koz-5, Koz-11, 
KozD-1, Ri-1.

Search pattern = oz-[1-3]    
Koz-1, Koz-2, Koz-11

Search pattern = oz-|Bl- 
Bl-1, Bl-2, Bl-3, Koz-1, Koz-2, Koz-5, Koz-11

## End(Not run)

[Package GCDkit version 4.0 Index]