dacă substring nu în python șir
fullstring = "StackAbuse"
substring = "tack"
if fullstring.find(substring) != -1:
print "Found!"
else:
print "Not found!"
Cum pot verifica dacă un șir conține un anumit cuvânt?
$a = 'Hello world?';
if (strpos($a, 'Hello') !== false) { //PAY ATTENTION TO !==, not !=
echo 'true';
}
if (stripos($a, 'HELLO') !== false) { //Case insensitive
echo 'true';
}
găsiți string în string python
>>> str = "Messi is the best soccer player"
>>> "soccer" in str
True
>>> "football" in str
False