From 3d63dc4ac7bd4992584920b240d75464c90736f4 Mon Sep 17 00:00:00 2001 From: Mikel Date: Tue, 5 Dec 2023 00:46:55 +0100 Subject: [PATCH] Fix Bio regular expressions (#378) * Add bioPart std::vector * Adjust bio vector * Add bio() method to the Person class * Add bioSupporter and bioFormats vector * Add bio() method implementation * Add test for the Person bio * Add BioHelper to check if the bio generated is valid * Add method to the Internet class to check if an emoji is valid * Implement BioHelper::checkTokenFormat() * Add missing includes * Adjust regex expressions * Add comment to checkIfEmojiIsValid() method * Adjust regex matching * Delete useless std::cout * Format code * Fix regular expressions --- src/common/BioHelper.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common/BioHelper.cpp b/src/common/BioHelper.cpp index 15ec5fc22..8e04e4139 100644 --- a/src/common/BioHelper.cpp +++ b/src/common/BioHelper.cpp @@ -8,14 +8,14 @@ namespace faker { bool BioHelper::checkTokenFormat(const std::string& bio) { - const std::regex firstRegex{R"(^[a-zA-Z0-9_]+$)"}; + const std::regex firstRegex{R"(^(\w+\s?\w+)$)"}; const std::regex secondRegex{R"(^(\w+\s?\w+), (\w+\s?\w+)$)"}; const std::regex thirdRegex{R"(^(\w+\s?\w+), (\w+\s?\w+), (\w+\s?\w+)$)"}; const std::regex fourthRegex{R"(^(\w+\s?\w+), (\w+\s?\w+), (\w+\s?\w+), (\S+)$)"}; - const std::regex fifthRegex{R"(^(\w+) (\w+)$)"}; - const std::regex sixthRegex{R"(^(\w+) (\w+) (\S+)$)"}; - const std::regex seventhRegex{R"(^(\w+) (\w+), (\w+\s?\w+)$)"}; - const std::regex eigthRegex{R"(^(\w+) (\w+), (\w+\s?\w+) (\S+)$)"}; + const std::regex fifthRegex{R"(^(\w+\-?\w+) (\w+)$)"}; + const std::regex sixthRegex{R"(^(\w+\-?\w+) (\w+) (\S+)$)"}; + const std::regex seventhRegex{R"(^(\w+\-?\w+) (\w+), (\w+\s?\w+)$)"}; + const std::regex eigthRegex{R"(^(\w+\-?\w+) (\w+), (\w+\s?\w+) (\S+)$)"}; std::smatch matches; //