From 71e04d8327335e7d77f5b624ea7764cff6bc8e84 Mon Sep 17 00:00:00 2001 From: Woochanlee Date: Mon, 14 Mar 2022 19:02:09 +0900 Subject: [PATCH] libaurum: Change text matching way to avoid use regex regex can't search text which has '(' Change-Id: I7ca10cb75ba77753e0c0d215b91799d53d429cad --- libaurum/src/PartialMatch.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libaurum/src/PartialMatch.cc b/libaurum/src/PartialMatch.cc index c1cd80a..54332b4 100644 --- a/libaurum/src/PartialMatch.cc +++ b/libaurum/src/PartialMatch.cc @@ -26,10 +26,18 @@ using namespace Aurum; bool PartialMatch::checkCriteria(const std::string textA, const std::string textB, const bool textPartialMatch) { - std::regex re(textA); + if (textB.empty()) return true; + bool rst; - if (textPartialMatch) rst = !(!!std::regex_search(textB, re) == true); - else rst = !(!!std::regex_match(textB, re) == true); + if (textPartialMatch) { + if (textB.find(textA) != std::string::npos) rst = false; + else rst = true; + } + else { + if (!textA.compare(textB)) rst = false; + else rst = true; + } + return rst; } -- 2.7.4