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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "RegExp Help Needed!" Watch "RegExp Help Needed!" New topic
Author

RegExp Help Needed!

Emile Ghazzawi
Greenhorn

Joined: Dec 30, 2002
Posts: 28
Hi,

I'm in need of a regular expression to meet the following formatting rules:

1. The length of the input must be bigger than 0 and less/equal to 14.
2. Only letters 'a' to 'z', '-' (dash) and ' ' (space) are allowed.
3. The '-' and ' ' letters must be entered.
4. The '-' or the ' ' letter must not be either the first or last letter entered.
5. '-' must not be the immediate neighbour or adjacent to a ' '.
6. '-' or ' ' must no be the immediate neighbour of itself.

I am not very familiar with JavaScript or the RegExp function and therefore any help in constructing the needed code is much appreciated!

Thanks in advance,

Emile
Emile Ghazzawi
Greenhorn

Joined: Dec 30, 2002
Posts: 28
Has anybody got any idea on this subject? Any help with the RegExp function would be hugely appreciated!

Thanks in advance,

Emile
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
I think it might have to be done in multiple parts and not in one statement....

I will play with it this morning...

Eric
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
This is ugly, but I think it gets the job done....



Eric
 
 
subject: RegExp Help Needed!