Hello, I want a given string to match a certain pattern and I am using the following function
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