File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Validator RegExp for Telephone Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Validator RegExp for Telephone" Watch "Validator RegExp for Telephone" New topic
Author

Validator RegExp for Telephone

Wagner Danda Da Silva Filho
Ranch Hand

Joined: Mar 21, 2003
Posts: 80
Hi All,

I need a help to create a regular expression to validate telephone field with Struts Validator. The regexp should be very simple: 4 numeric digits, a "-" char, and again more 4 numeric digits. Ex: "3131-3131".

Any ideias?


SCJP, SCWCD
Wagner Danda Da Silva Filho
Ranch Hand

Joined: Mar 21, 2003
Posts: 80
I found this solution:

\d{4,4}-\d{4,4}

In struts validation.xml:

<field property="phone" depends="required,mask">
<arg0 key="client.phone"/>
<var><var-name>mask</var-name>
<var-value>^\d{4,4}-\d{4,4}$</var-value></var>
</field>



Wagner Danda
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validator RegExp for Telephone
 
Similar Threads
String array generation with distinct values
WA #1.....word association
Weird unicode translation problem
help
How to combine JSP <c:if> with JSF <f:validateLength>