Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test a string for a substring [duplicate]

Tags:

python

string

Is there an easy way to test a Python string "xxxxABCDyyyy" to see if "ABCD" is contained within it?

like image 646
Nate Avatar asked Mar 29 '11 13:03

Nate


People also ask

How do you check if a character repeats in a string?

you can use . indexOf() and . lastIndexOf() to determine if an index is repeated. Meaning, if the first occurrence of the character is also the last occurrence, then you know it doesn't repeat.


1 Answers

if "ABCD" in "xxxxABCDyyyy":     # whatever 
like image 102
Sven Marnach Avatar answered Oct 08 '22 19:10

Sven Marnach