I’m wondering if there is a function like preg_match in PHP where I can find or match a string with another string.
//In Array `word` // in array `part`
"Backdoor", 0 "mark" 3 (matches "Market")
"DVD", 1 "of" 2 (matches "Get off")
"Get off", 2 "" -1 (no match)
"Market", 3 "VD" 1 (matches "DVD")
I’m thinking that if there is a function that can match just part of the string it would be great, but as far as I know there is only strcmp but that will only compare if is match or not for the whole string in which my case will always be false.
std::strstr(). It doesn’t do regexes, but it does do simple string-in-string matching.And as you’re in C++, there’s also
std::string::find():