Repository URL to install this package:
Version:
0.1.0a1 ▾
|
py-kaos-utils
/
string.py
|
---|
import re
def create_initials(s: str) -> str:
"""
Return the initial letter of each word in `s`, capitalized and strung together
Example: John Smith -> JS
:param s: String to create initials out of
:return: Initials of `s`, capitalized
"""
return "".join(s[0] if s else '' for s in re.split(r"[\W_]+", s)).upper()