[rt-users] Regular Expressions for Custom Field Validation in RT3.6.0

Todd Chapman todd at chaka.net
Mon Jun 26 11:48:10 EDT 2006


On Mon, Jun 26, 2006 at 08:22:46AM -0700, Schultz, Eric wrote:
> I know what you mean, and I did something like that in my code that I
> backported from 3.5.x to 3.4.x.  I added another regex field that said
> whether something was mandatory or not, where 1 is mandatory, and 0 is
> not:
> 
> (?#Year)(?#0)^[12]\d{3}$            year, not mandatory
> (?#Mandatory)(?#1).                 anything, mandatory
> (?#postal code)(?#1)^[A-Z]{2}$      postal code, mandatory
> 
> The second one is useful for a field where you want anything, don't care
> how long or what it looks like, so long is it isn't left blank.
> Obviously, I hacked on the RT code a little that reads this stuff to
> accomodate for the second regex group.
> 
> Eric Schultz
> United Online

Eric,

Why add the second regex group when you can wrap the whole
thing in ()? ?

-Todd



More information about the rt-users mailing list