In the introduction we have matched two basic strings.
This is quite simple to do with QRX:
| QRX | Text to match | Error |
|---|---|---|
| phone number | phone mumber | 1 character |
In many cases we have knowledge about the type of
characters (number, upper character, lower character, special character) which
appear in the text. QRX offers a simple way to express that fact.
There are 4 common classes:
| Class | Usage |
|---|---|
| N | Numbers (0-9) |
| T | Upper letters |
| t | Lower letters |
| S | Special characters |
Example: An
The QRX syntax for one single number is “N”. Therefore
a zip code can be expressed by “NNNNN”!
| QRX | Text to match | Error |
|---|---|---|
| NNNNN | 88123 | 0 characters |
| QRX | Text to match | Error |
|---|---|---|
| NN.NN.NN | 12.02.1976 | 0 characters |
Another example:
| QRX | Text to match | Error |
|---|---|---|
| My (first|second|third) beer | My second beEr | 1 character |
In QRX we have the ability to give several
alternatives to a notation. The alternatives are separated by the character
“|”.
| QRX | Text to match | Error |
|---|---|---|
| Jan|Feb|Mar|Apr | Fed | 1 character |
| QRX | Text to match | Error |
|---|---|---|
| NN.NN.NN|NNNN | 12.02.1976 | 2 characters |
| QRX | Text to match | Error |
|---|---|---|
| NN.NN.(NN|NNNN) | 12.02.1976 | 0 characters |
| QRX | Text to match | Error |
|---|---|---|
| My t{5,12} beer | My ninth beer | 0 characters |
| QRX | Text to match | Error |
|---|---|---|
| My number is [01]{1,10} | My number is 001x0001 | 1 character |
As we already know there are existing several characters with a special meaning in the QRX syntax (“N”,”t”,”T”,”S”,”[“,”|”,..). If we want to use one of these characters as a native character, we have to insert the “@”-character directly before the relating letter.
Example: The upper “N” in number is interpreted as an number-class! The result is an 1 error distance! To solve this problem, use “@N”!
Annotation: This effect is not very common, in almost very case it is not necessary to look for those constellations!
| QRX | Text to match | Error |
|---|---|---|
| myNumber | myNumber | 1 characters! Because N is a symbol for numeric values! |
With @-operator we get:
| QRX | Text to match | Error |
|---|---|---|
| my@Number | myNumber | 0 character |
| Expression | Match |
|---|---|
| x
@x X|Y (X) X{n,m} [abc] N T t S |
The character x, if x is no spezial
character. The character x (De-Reference) X or Y Group X with minimum n, maximum m repetitions (0 < n <= m). Characters a, b or c 0 to 9 (Numeric) A to Z (upper terminals) a to z (lower terminals)
Special Characters: Equals PERL notation: [^0-9A-Za-z\x7B-\x80] |
| QRX Version | Reserved Character |
|---|---|
| 1.0 | (){}[]|,NTtS@; |
| Not supported Perl Term | Description |
|---|---|
|
X* X+ X? ^ $ . [a-z] \n \t \d |
X any times X at least once X or none Start of Line End of Line Any Character Characters 'a' to 'z'. Note: In QRX notation:t. New line. Tab [0-9]. Note: In QRX notation:N. |
| QRX Expression | Examplematch |
|---|---|
|
Hello? @Telephone: N{3,5}/N{3,20} Da@te: (N{1,2}.N{1,2}.N{2,4}|N{4,4}/N{2,2}/N{2,2}) Vorname: [Tt]{2,20}, @Nachname: [Tt]{2,20}. Produc@t code: TTT-N{5,5}-[ABCDEFN] |
Hello? Telephone: 0123/45678 Date: 2004/03/08 Vorname: Fritz, Nachname: Mueller.
Product code: IBN-12345-3 |
| Term | |
|---|---|
| QRX | Selection |
| Selection | Concartenation '|' Concartenation '|' Selection |
| Concartenation | '(' Selection ')' | Concartenation Concartenation | CharacterSpec |
| CharacterSpec | ( '@' AnyCharacter | 'N' | 'T' | 't' | 'S' | CharacterClass | NonSpecialCharacter ) ( AreaSpec )? |
| CharacterClass | '[' ( CharacterClassItem )+ ']' |
| CharacterClassItem | '@' AnyCharacter | 'N' | 'T' | 't' | 'S' | NonSpecialCharacter |
| AreaSpec | '{' PositiveInteger ; PositiveInteger '}' |
| PositiveInteger | [0-9][0-9]* |