ak podreťazec nie je v reťazci python
fullstring = "StackAbuse"
substring = "tack"
if fullstring.find(substring) != -1:
print "Found!"
else:
print "Not found!"
Ako môžem skontrolovať, či reťazec obsahuje konkrétne slovo?
$a = 'Hello world?';
if (strpos($a, 'Hello') !== false) { //PAY ATTENTION TO !==, not !=
echo 'true';
}
if (stripos($a, 'HELLO') !== false) { //Case insensitive
echo 'true';
}
nájsť reťazec v string python
>>> str = "Messi is the best soccer player"
>>> "soccer" in str
True
>>> "football" in str
False