I have a text file containing the following text
License = "123456"
GeneralLicense = "56475655"
I want to find Licenseas well for GeneralLicense.
while (getline(FileStream, CurrentReadLine))
{
if (CurrentReadLine.find("License") != std::string::npos)
{
std::cout << "License Line: " << CurrentReadLine;
}
if (CurrentReadLine.find("GeneralLicense") != std::string::npos)
{
std::cout << "General License Line: " << CurrentReadLine;
}
}
Since the word is Licensealso present in the word GeneralLicense, therefore if-statement, the line if (CurrentReadLine.find("License") != std::string::npos)becomes true twice.
How can I indicate that I want to find the exact substring?
UPDATE: I can reverse the order mentioned in some answers, or check if Licensethe index is zero. But is there something ROBOUST (flag or something else) that we can describe to find an exact match ( . Something similar to most editors, for example, MS Word, etc. ).