Проблема с Regex 100 ++C++

Программы на C++. Форум разработчиков
Anonymous
Проблема с Regex 100 ++

Сообщение Anonymous »

Я работал с Regex в своем проекте в C# и работал, как и ожидалось. Я переместил резервуар в C ++, и регулярное выражение давало всегда ложь, даже с действительной строкой, которую я создал. < /P>
// dllmain.cpp : Defines the entry point for the DLL application.
#include "pch.h"

#include
#include
#include
#include // For memset

extern "C" __declspec(dllexport) bool ValidateWithRegex(const char* input, int length, const char* pattern)
{
// Convert the byte array (UTF-8 encoded) into a std::string
// std::string inputStr(input, length); // Convert char* (UTF-8) to std::string
std::string utf8String = "123312";
// std::string utf8String(input);

// Create the regex object with the passed pattern
std::regex regexPattern("^[a-zA-Z0-9\\W]{6,6}$");

// Check if the input value matches the regex pattern
bool isValid = std::regex_match(utf8String, regexPattern);

// After validation, overwrite the string buffer
std::memset(&utf8String[0], 0, utf8String.size()); // Overwrites the internal memory of the string

return isValid;
}

< /code>
Когда я вызову validatewithregex вывод всегда ложный. Я проверил входные данные действительны и правильные и Trimd. Я протестировал все шаги раньше и не обнаружил ошибок, но выходной сигнал не работает

Подробнее здесь: https://stackoverflow.com/questions/794 ... regex-in-c

Вернуться в «C++»