Select to view content in your preferred language

How to do Multiple Regular Expression Checks in a Single Field

3629
5
Jump to solution
08-27-2013 05:28 PM
TedCronin
MVP Alum
Is it possible to use an Or inside of a Regular Expression Check somehow, for example as TR 12345 or TR 1234, something to the effect of [A-Z][A-Z] [0-9][0-9][0-9][0-9][0-9] OR [A-Z][A-Z] [0-9][0-9][0-9][0-9].

I know the above does not work, but what is the recommended approach for doing Multiple Regular Expression Checks in a Single Field.

Another Occurrence would be TR 12345 OR TR 12345-1, because conceptually I can solve this (TR 12345 or TR 1234) as

[A-Z][A-Z] [0-9]+
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MichelleJohnson
Esri Contributor
Use | as the OR.  For example,

TR 12345-1 OR TR 12345 OR TR 1234
([A-Z][A-Z] [0-9][0-9][0-9][0-9][0-9]\-[0-9])|([A-Z][A-Z] [0-9][0-9][0-9][0-9][0-9])|([A-Z][A-Z] [0-9][0-9][0-9][0-9])

MB 000/000 SD OR MB 000/000
([A-Z][A-Z] [0-9][0-9][0-9]\/[0-9][0-9][0-9] [A-Z][A-Z])|([A-Z][A-Z] [0-9][0-9][0-9]\/[0-9][0-9][0-9])

Cheers,
michellej.

View solution in original post

0 Kudos
5 Replies
GISDev1
Deactivated User
In you use-case examples, multiple expressions don't seem to be necessary.
What's wrong with the "+" solution you posted?
0 Kudos
TedCronin
MVP Alum
Absolutely, that does work, but what I really need is where I have a Tract with a number and a Tract with a -1 at the end.  Really bad example on my part I suppose, since I already use the [A-Z][A-Z] [0-9]+ where I can do exactly what I asked such as grabbing a 4 + digits. 


Other examples where I need an OR MB 000/000 OR MB 000/000 SD...
0 Kudos
TedCronin
MVP Alum
It would be nice to add to the Composite Check the ability to add a SQL Check and then combine the SQL Check with a Regular Expression Check, or even a couple of Regular Expressions Checks where, I can Extract out what I am referring here in an OR via SQL, then be able to stack multiple Reg Expressions, essentially.
0 Kudos
MichelleJohnson
Esri Contributor
Use | as the OR.  For example,

TR 12345-1 OR TR 12345 OR TR 1234
([A-Z][A-Z] [0-9][0-9][0-9][0-9][0-9]\-[0-9])|([A-Z][A-Z] [0-9][0-9][0-9][0-9][0-9])|([A-Z][A-Z] [0-9][0-9][0-9][0-9])

MB 000/000 SD OR MB 000/000
([A-Z][A-Z] [0-9][0-9][0-9]\/[0-9][0-9][0-9] [A-Z][A-Z])|([A-Z][A-Z] [0-9][0-9][0-9]\/[0-9][0-9][0-9])

Cheers,
michellej.
0 Kudos
TedCronin
MVP Alum
Sweeet.

Cheers Indeed.

I was not seeing the expected results with just using Spaces, but explicitly insert white Space seems to do the trick.

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


Seems like the | can get inserted into the Help for OR, what is the symbol for AND.  Currently | is Matches an alternative phrase or spelling, in the help.

I also like how you use () and use \ for even /...
0 Kudos