Suppose i have string like S="python (unix)" and i want to get following output : Python (Unix). Please suggest me.
How to solve above when senetence is to read from text file in Python?
Here is one approach, using re.sub
with a callback function which capitalizes each matching word:
S = "python (unix)"
out = re.sub(r'\b\w+\b', lambda m: m.group().capitalize(), S)
print(out)
This prints:
Python (Unix)