I want to abbreviate words from a string by writing a python script. for example, I studied in King Saud University, which is in Riyadh, the capital of Saudi Arabia; becomes I studied in KSU, which is in Riyadh, the capital of SA.
I tried to use the lambda, to scan all the string but I couldn't remove the rest of the word after finding it.
import re
str = "I studied in King Saud University, which is in Riyadh, the capital of Saudi Arabia"
result = re.sub(r"\b[A-Z]", lambda x: x.group() ,str)
print(result)