I need to determine if a string is a variable identifier.
i.e. (a-z,A-Z,,$) followed by (a-z开发者_如何学Python,A-Z,0-9,,$)
I know I can do it with a manually configured reg exp, but there must be a more compact, built in function I can use.
Any solutions?
You can use the methods Character.isJavaIdentifierStart()
and Character.isJavaIdentifierPart()
but I don't think the solution will be more compact.
EDIT: I decided to search and found this in Codemodel: http://codemodel.java.net/nonav/apidocs/com/sun/codemodel/JJavaName.html
精彩评论