Hello,
I have problems determining valid Java package names using Python. Here's the code:
packageName = "com.domain.lala" # valid, not rejected -> correct
#packageName = ".com.domain.lala" # invalid, rejected -> correct
#packageName = "com..domain.lala" # invalid, not rejected -> incorrect
#packageName = "com.domain.lala." # invalid, not rejected -> incorrect
matchObject = re.match("([a-z_]{1}[a-z0-9_]*(\.[a-z_]{1}[a-z0-9_]*)*)",
packageName)
if matchObject is not None:
print packageName + " is a package name!"
else:
print packageName + " is *not* a package name!"
Utilities.show_error("Invalid Package Name", "Invalid package name " + packageName + "!", "Ok", "", "")
Package names must start with a lowercase letter or underscore and each dot must be followed by at least one lowercase letter or underscore again. All other characters can be lowercase letters, digits, or an underscore. No runs of dots are allowed and it may not end with or start with a dot.
How do I solve this?