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

Schultz, Eric ESchultz at corp.untd.com
Mon Jun 26 12:52:42 EDT 2006


I think that may break the regex parsing in MatchPattern() in
CustomField_Overlay.pm.  Unless you are talking about doing something
like:

(?#Year)^[12]\d{3}$

becomes

(?#Year)(^[12]\d{3}$)?

Give it a try and let me know how that works for you :-)

Eric Schultz
United Online

-----Original Message-----
From: Todd Chapman [mailto:todd at chaka.net] 
Sent: Monday, June 26, 2006 8:48 AM
To: Schultz, Eric
Cc: Nick Metrowsky; rt-users at lists.bestpractical.com
Subject: Re: [rt-users] Regular Expressions for Custom Field Validation
in RT3.6.0

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