Regular Expression Question

Hi all,

I am suffering in java regular expression, and I hope you guys can help me out. I want to use the String api ".matches" to find out any string pattern like "xxxx.xxxx" where xxx can be only english word(both upper and lower case). Actually I will use this kind of expression to represent the cross join SQL statement in my java class, like "tableA.name = tableB.name", where they should be english letter only. I tried to use MyString.matches("^[A-Z] + \\. + ^[A-Z]") in my java program, but seem it doesn't work. Can you guys figure out the right expression for me ? Many thanks

Transistor

[619 byte] By [popohomaa] at [2007-10-3 10:53:49]
# 1
MyString.matches("[A-Za-z]+\\.[A-Za-z]+")
sabre150a at 2007-7-15 6:19:33 > top of Java-index,Other Topics,Algorithms...
# 2

Thanks for your prompt response, I tried your code, however, it doesn't work out.

I put your code like the following:

if ( searchCriteria.getStringPair().getValue().trim().matches("[A-Za-z]+\\.[A-Za-z]+") {...some action }.

Seems the java program never reach this expression.

Kindly remind that I wan to expression anything like "xxxxx.xxxxx" where xxxx can be a word.

Myriads of thanks

Transistor

popohomaa at 2007-7-15 6:19:33 > top of Java-index,Other Topics,Algorithms...
# 3
Post an example of the value of searchCriteria.getStringPair().getValue().trim() because String value = "abc.defghjij";System.out.println(value.matches("[A-Za-z]+\\.[A-Za-z]+"));prints 'true'.
sabre150a at 2007-7-15 6:19:33 > top of Java-index,Other Topics,Algorithms...
# 4
thanks man, I think I made a mistake, since my string is "aset_typ_cde" which includes "_", that's why it was not working before. I think I should *** the "_" regular expression in between.Myriads of thanks
popohomaa at 2007-7-15 6:19:33 > top of Java-index,Other Topics,Algorithms...