Find substring in a string : String find « String « Python






Find substring in a string


S = 'xxxxSPAMxxxxSPAMxxxx'
where = S.find('SPAM')          # search for position
print where                           # occurs at offset 4

           
       

Related examples in the same category

1.String search: search for positionString search: search for position