I'd like to write a function that matches in a string and returns all uppercase letters that are not followed by a lowercase letter.
def find_sub_string(text, pattern):
if re.search(pattern, text):
return re.findall(pattern, text)
else:
return None
Here is an example of a desired output:
>>> find_sub_string('AaAcDvFF(G)F.E)f', pattern)
>>> ['F', 'F', 'G', 'F', 'E']
What should be the right pattern in that case?
I tried pattern='[A-Z][^a-z]
, but it produce the following output ['FF', 'G)', 'F.', 'E)']
, which satisfies the described condition, except it returns two letters except one.