• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

RegExp Help Needed!

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Has anybody got any idea on this subject? Any help with the RegExp function would be hugely appreciated!

Thanks in advance,

Emile
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is ugly, but I think it gets the job done....



Eric
 
Squanch that. And squanch this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic