i am trying to code a search function to search in strings and find the word
like the php + mysql for example
Select * From Column Where ID Like %Word%
i tried to code the same idea with Preg match all and regex
Here is my code
$strings = '
( monstername 205 "Devil Troop of Desire")
( monstername 206 " Devil Troop of Pain " )
( monstername 207 "Devil Troop of Greed")
( monstername 208 " Devil Troop of Jealousy ")
( monstername 207 "Mask Troop of Greed" )';
preg_match_all('/monstername\s*(.*?)\s*\"\s*\\b(Jealousy)\b\s*\"\s*\)/i', $strings, $matches, PREG_SET_ORDER);
foreach ($matches as $match){list (, $MonsterNumber) = $match;
echo "$MonsterNumber";
}
the output should be
208
but it dont display the output correct
it display it when i replace Jealousy With Devil Troop of Jealousy
i just want to do the same idea of php + mysql
Where ID Like %Word%
without give the full string to find the number of monster
The part
"\s*\\b(Jeadoes not allow for other characters than whitespace between the quote and the start of the word. You probably wanted any char (or even none?) between them, like".*\\b(Jeaand the same problem after the word.