Dates

Top  Previous  Next

Scripts > Token definitions > Predefined tokens > Dates

 

The following predefined tokens can be inserted in a project by a pop-up menu.

 

The classes of possible recognitions of the following dates are overlapping. You only should use one of them in one project or be sure what you are doing. The expressions are kept general. So are recognized next to 4-digit also 2-digit dates and different separators are allowed. For a concrete application the expressions should be specified as far as possible.

 

 

 

DD_MM_YYYY:

(0[1-9]|[12][0-9]?|3[01]?|[4-9])[-./] \// day

(0[1-9]|1[0-2]?|[2-9])[-./] \//month

(\d\d|\d{4,4}) //year

 

This expression recognizes date like: 03.02.56; 3.2.1856; not valid dates like 31.2.9999 are not excluded.

 

Remark: Each of the parenthesis of the expression contains exactly one part of the date. So day, month and year can be easily obtained by:

 

str sDay = xState.str(1);

str sMonth = xState.str(2);

str sYear = xState.str(3);

 

The regular expression is optimized according to the LL(1)-principle. It begins with alternatives, which exclude each other. For example the 31 days of a month must begin with a preceding 0 or by another digit. Each digit only can be followed by specific other digits.

 

 

alternative

begin

range

0 [ 1-9 ]

0

01, 02, 03, 04, 05, 06, 07, 08, 09

| [ 12 ] [ 0-9 ]?

1

1 oder 10 - 19

 

2

2 or 20 - 29

| 3 [ 01 ]?

3

3 or 30 or 31

| [ 4-9 ]

4

4

 

5

5

 

6

6

 

7

7

 

8

8

 

9

9

 

 

YYYY_MM_DD:        

(\d\d|\d{4,4})[-./] \// year

(0[1-9]|1[0-2]?|[2-9])[-./] \// month

(0[1-9]|[12][0-9]?|3[01]?|[4-9]) //day

 

This expression is a simple rearrangement of the expression above. It recognizes dates like  56.03.02; 1856.3.2; not valid dates like 9999.31.2 are not excluded.

recognizes



This page belongs to the TextTransformer Documentation

Home  Content  German