View Single Post
  #1 (permalink)  
Old 07-17-2007, 06:46 PM
romina romina is offline
Member
 
Join Date: Jul 2007
Posts: 26
romina is on a distinguished road
I can't find the right regular expression
Hello, I want a given string to match a certain pattern and I am using the following function
Code:
public boolean matches(String regex) from java.lang.String
The constraints the strings have to satisfy are the following
  • At least 2 letter a-zA-z
  • Zero or more times an apostrophe (')
  • Zero or more times a space
for example James o'Hara is valid string.

The problem is I can't find the right pattern/regular expression.

I tried this: string.matches([a-zA-Z]{2,}[ ']*) but the example didn't work.
Can anyone help me? I am using eclipse and Java5.0
Thanks
Reply With Quote
Sponsored Links