I have started learning Python, yeah the scripting language.
It is very powerful... this is a tip i couldn't find in the net...
This code snippet cuts off any non-alphanumeric characters from the start of the string message
, including unicode (like \xa2
).
temp = ""
f = False
for j in message:
if f == False:
if curses.ascii.isalnum(j):
f = True
temp = temp + j
else:
temp = temp + j
message = temp
You can change the script to crop off anything other that characters by changing
isalnum
to isalpha
.Courtesy: Balagopal
0 comments:
Post a Comment