Py In My Eye
Python 3, Tkinter, PyQt4, snippets, etc.
Monday, April 30, 2012
Find unique characters in a string
An example of finding unique characters in a string using
set
and
re
testStr = 'AAA 7 BBBB C 1 DDD d Y ZZ 3'
''.join( set(re.findall(r'[a-zA-Z]',testStr)) )
Output:
'ACBDYZd'
Newer Posts
Older Posts
Home
View mobile version
Subscribe to:
Posts (Atom)