Mega Code Archive

 
Categories / Python / String
 

String search

S = 'xxxxSPAMxxxxSPAMxxxx' where = S.find('SPAM')          # search for position print where                            S = S[:where] + 'EGGS' + S[(where+4):] print S