> Like .abc , .abc#1 , .abc#2 > > I want that if i encounter such kind of name then it should be converted to > .abc string.split('#') will do that for you: >>> print 'abc#2'.split('#')[0] 'abc' Alan G.