• 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

A simple RegEx just doesn't make sense...

 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Just wondering if someone could explain the obvious issue with the below regEx and why is does NOT allow numbers...

"^[A-Za-z0-9 ]{3,50}$"

A couple of simple tests both of which I would expect to be OK, but test 2 fails:-

Test 1: "This is a string" = OK
Test 2: "This is a string 123" = NOT OK

Cheers in advance
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kev Bellion wrote:
Just wondering if someone could explain the obvious issue with the below regEx and why is does NOT allow numbers...

"^[A-Za-z0-9 ]{3,50}$"

A couple of simple tests both of which I would expect to be OK, but test 2 fails:-

Test 1: "This is a string" = OK
Test 2: "This is a string 123" = NOT OK

Cheers in advance



What you describe doesn't make sense. Can you post some code that shows this ?

Henry
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Both succeed for me:
 
Kevin P Smith
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:

Kev Bellion wrote:
Just wondering if someone could explain the obvious issue with the below regEx and why is does NOT allow numbers...

"^[A-Za-z0-9 ]{3,50}$"

A couple of simple tests both of which I would expect to be OK, but test 2 fails:-

Test 1: "This is a string" = OK
Test 2: "This is a string 123" = NOT OK

Cheers in advance



What you describe doesn't make sense. Can you post some code that shows this ?

Henry



Basically...
 
Kevin P Smith
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:Both succeed for me:



Yes, OK Eclipse is c--p!
Tried your example above and it worked for me too, which I'd expect as the RegEx (as far as I know) is correct.
Done a complete clean of my project in Eclipse and clean deploy (where it wipes your entire old app and re-deploys to the server rather than a standard deploy that just replaces file that have changed) and what you know, it works!!!
So it was some sort of Eclipse issue, not a code issue.
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Glad you figured it out -- as I was about to report that it works for me too.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic