You may or may not have heard of Willie, the Python IRC bot.
I have a trigger.group(2) object:
'J O I N : # S t a f f'
How do I make this become:
'JOIN :#Staff'
Edit:
Basically I want to remove the spaces between the characters without removing the "real" spaces, between N :. Note that the command could be anything with any number of arguments: PRIVMSG, OPER, etc.
Since you have alternating spaces and non-spaces, try taking every second character:
s = s[::2]
Example:
>>> 'J O I N : # S t a f f'[::2]
'JOIN :#Staff'
>>> import re
>>> text = 'J O I N : # S t a f f'
>>> re.sub(r'(?<=\S)\s|\s(?=\S)', '', text)
'JOIN :#Staff'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With