[Opensource] regular expression
Jan.Moons at alcatel.be
Jan.Moons at alcatel.be
Thu Jan 16 00:31:51 PST 2003
Best practices request on adding ControllerSecurity rowsHi David,
Are you asking how to use struts validator ?
Or just how regular expressions look like ?
Well, a regular expression is a string of characters that define a pattern used to search for a matching string. You can read more about regular expressions and how they can be used at the following location :
http://www.javaworld.com/javaworld/jw-07-2001/jw-0713-regex_p.html
Or go to the site of the man who implemented struts validator :
http://home.earthlink.net/~dwinterfeldt/
At the moment I am woking on a Struts project that uses struts validator for validating user input (client and server side) and here is a piece of my validation.xml it should be self explaining :
<form-validation>
<global>
<!-- personnel numbers start with 3 zeros followed by 5 digits -->
<constant>
<constant-name>personnelNumber</constant-name>
<constant-value>^0{3}\d{5}$</constant-value>
</constant>
<!-- upi begins with 2 letters, followed by a letter or zero and then 6 digits -->
<constant>
<constant-name>upi</constant-name>
<constant-value>^[A-Z]{2}[A-Z|0]\d{6}$</constant-value>
</constant>
</global>
<formset>
<form name="thrcsVasteGegevensForm">
<field property="upi" depends="required,mask">
<!-- hr.upi.maskmsg is defined in Struts ApplicationResources.properties -->
<msg name="mask" key="hr.upi.maskmsg"/>
<arg0 key="hr.upi"/>
<var>
<var-name>mask</var-name>
<var-value>${upi}</var-value>
</var>
</field>
<field property="personnelNumber" depends="required,mask">
<msg name="mask" key="hr.personnelNumber.maskmsg"/>
<arg0 key="hr.personnelNumber"/>
<var>
<var-name>mask</var-name>
<var-value>${personnelNumber}</var-value>
</var>
</field>
<field property="csType" depends="required">
<arg0 key="thrcsVasteGegevens.csType"/>
</field>
<field property="dateOfBirth" depends="timestamp">
<arg0 key="thrcsVasteGegevens.dateOfBirth"/>
</field>
</form>
</formset>
</form-validation>
Hopefully this helps you a bit further,
Jan
----- Original Message -----
From: David Zhao
To: 'opensource at jcorporate.com'
Sent: Wednesday, January 15, 2003 8:01 PM
Subject: [Opensource] regular expression
Hi there:
Does anybody know the "regular expression" syntax for struts common-validator? Thanks a lot,
David
**************************************************************************************************
The contents of this email and any attachments are confidential.
It is intended for the named recipient(s) only.
If you have received this email in error please notify the system manager or the
sender immediately and do not disclose the contents to any one or make copies.
** eSafe scanned this email for viruses, vandals and malicious content **
**************************************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.jcorporate.com/pipermail/opensource/attachments/20030116/a3043075/attachment-0002.htm
More information about the Opensource
mailing list