c# - Using a regular expression to find words with lower and upper case characters in parenthesis -
i'm creating program searches string finding words in parenthesis lower , upper case characters can't seem figure out regular expression use. example word - (lowerupper)
regular expression :
string upperlowerparens = "\\([a-z][a-z][a-z]+[a-z]+\\)";
try 1
\(([a-z]+[a-z]+)[a-za-z]*\)|\(([a-z]+[a-z]+[a-za-z]*)\)
- explanation
this divided 2 parts if 1 of them matched word between brackets matched
\(([a-z]+[a-z]+)[a-za-z]*\)
validates(lowerupper)
capital letters appears first\(([a-z]+[a-z]+[a-za-z]*)\)
validates(upperlower)
lower case letters appears first
f want allow spaces after , before brackets can change regex \( *([a-z]+[a-z]+)[a-za-z]* *\)|\( *([a-z]+[a-z]+[a-za-z]*) *\)
check demo here demo
Comments
Post a Comment