# PSPARQL regular expression patterns

## Introduction

Let *I* be the set of irirefs, *B* be the set of blanks, and
*X* be the set of variables.
The regular expression patterns used in the PSPARQL query language are constrcuted
inductively over *I*∪*B*∪*X* in the following way:

- ε is a regular expression pattern;
- ∀
*a*∈*I*∪*B*∪*X*, *a* and
*!a* are regular expression patterns;
- if
*A* and *B* are regular expression patterns, then *(A)*, *+A*, **A*, *A|B*, and *A.B* are regular expression patterns.

Where *+A* denotes the positive closure of *A*,
**A* denotes the Kleene closure of *A*,
*!a* denotes the negation of *a*,
*A|B* denotes the disjunction of *A* and *B*,
and *A.B* denotes the concatenation of *A* and *B*.
## Examples

The following regular expression pattern generates words of length at least one that contains `train` or `bus` repeated many times:

+(train | bus)

The following regular expression pattren generates words, which are of length two, that contains any symbol other than `train` followed by `avion`:

!train . avion

## Constrained regular expressions

The constrained regular expressions allowed in CPSPARQL Grammar
are the ones constructed over the set of urirefs, blanks, and variables.

We use { and } to denote the begining and the end of a constrained regular expression that will be
applied to the constraint. The inverse, positive and kleene operators will be prefixed.
For example, + ( {-ex:from} % const1 % . ex:to ) is a constraint regular expression, the constraint in this example will be applied
to the part -ex:from. See also the Grammar.

Feel free to comment to
Faisal Alkhateeb
$Id: regularexpressions.html,v 1.3 2008/12/10 20:01:37 euzenat Exp $