[Opensource] regular expression
David Zhao
david.zhao at celero.ca
Thu Jan 16 12:51:47 PST 2003
Hi Jan:
I want to validate some fields based on certain patterns and the links you
provided really helps, Thank you very much!
David
-----Original Message-----
From: Jan.Moons at alcatel.be [mailto:Jan.Moons at alcatel.be]
Sent: January 16, 2003 1:32 AM
To: opensource at jcorporate.com
Subject: Re: [Opensource] regular expression
Hi 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
<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/
<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 <mailto:david.zhao at celero.ca> Zhao
To: 'opensource at jcorporate.com' <mailto:'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 **
****************************************************************************
**********************
**************************************************************************************************
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/bc5b2999/attachment-0002.htm
More information about the Opensource
mailing list