use of Regular Expressions in Data reviewer checks?

3956
7
Jump to solution
05-22-2012 04:19 AM
MartinHvidberg
Occasional Contributor
Dear Forum

I???m trying to use Data Reviewer to catch invalid dates in a string (TEXT) field.

I use the "Regular Expression Check Properties" in "Table Checks".

My field holds date values of form YYYYMMDD, e.g. 19660313

I tried to write a Regular Expression to fit this, some thing like:
([0-9][0-9][0-9][0-9])(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|3[01])

But Data Reviewer keeps returning all records as errors, so obviously I???m doing something wrong.

Can anyone help me to a good R.E. expression, which would identify only the dates that do not match the YYYYMMDD format?

Best regards
Martin
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MichelleJohnson
Esri Contributor
Hello Martin,

Have you seen the example in the help documentation?

Try this: ((19)|(20))\d\d((0[1-9])|(1[012]))((0[1-9])|([12][0-9])|(3[01]))

I think you were missing a couple of sets of parenthesis.

View solution in original post

0 Kudos
7 Replies
MichelleJohnson
Esri Contributor
Hello Martin,

Have you seen the example in the help documentation?

Try this: ((19)|(20))\d\d((0[1-9])|(1[012]))((0[1-9])|([12][0-9])|(3[01]))

I think you were missing a couple of sets of parenthesis.
0 Kudos
TuanVu_Huu
New Contributor II

Dear Michelle,

I am Tuan from Esri Vietnam.

I am help customer in vietnam to build table check and I using Regular Expression check. I have try to check value field name of map sheet as like this : 6636-V-DN

And I have try expression as :  

([0-9][0-9][0-9][0-9])\-([A-Z])\-([A-Z][A-Z])

But it is not return the error. 

Moreover, when I have set some expression for other field it is work but it not check for NULL or Space value?

Please help!

Many thank in advance!

Vu Tuan

0 Kudos
TuanVu_Huu
New Contributor II

Dear Michelle,

sorry I mean I have typed expression as: 6636-V-DN 

([0-9][0-9][0-9][0-9]-\[A-Z]-\[A-Z][A-Z])  too

But still not get error.

many thanks,

Vu Tuan

0 Kudos
MichelleJohnson
Esri Contributor

Vu Tuan,

There is an option to check for NULLs.  It will not flag fields with blanks.  But I think that the expression should flag those.  If it does not, then you can create an Execute SQL Check to look for NULL and blanks.

Regards,

michellej.

0 Kudos
TuanVu_Huu
New Contributor II

Dear Michelle,

I have added some option, But still fail.

([0-9][0-9][0-9][0-9]\-\[A-Z]\-\[A-Z][A-Z])

([0-9][0-9][0-9][0-9])\-([A-Z])\-([A-Z][A-Z])

([0-9][0-9][0-9][0-9]-[A-Z]-[A-Z][A-Z])

Please advice

Vũ Tuấn

0 Kudos
MichelleJohnson
Esri Contributor

Hello Vu Tuan,

I used the last option you provided, ([0-9][0-9][0-9][0-9]-[A-Z]-[A-Z][A-Z]), and I was getting expected results.  I'm assuming that your format must be like 6636-V-DN. 

I created sample data with good and bad formatting.  The highlighted records were returned.  They do not follow format of 4 digits, dash, 1 capital letter, dash, 2 capital letters.

Regards,

michellej.

0 Kudos
MartinHvidberg
Occasional Contributor
Thanks Michelle

Your RE. is perfect, thanks for that.
Also thanks for the link.

🙂 Martin
0 Kudos