Answer the question
In order to leave comments, you need to log in
What causes object regex = Error when reading the characters of a string?
I have a program, there is a regex object. The program has Html text. The same code as here works fine in the main function, but here the regex object is not equal to - <.+>, but is equal to - <Error reading characters of the string.>.
#include "Parsing.h"
Parsing::Parsing(){
}
void Parsing::Parse(string Html){
cmatch result;
regex regular("<.+>");
if (regex_match(Html.c_str(), result, regular)){
cout << "true!";
}
}
#pragma once
#include <regex>
#include "Request.h"
class Parsing{
public:
Parsing();
void Parse(string Html);
cmatch result;
regex regular;
};
Answer the question
In order to leave comments, you need to log in
In your program, regular is both a member of the Parsing class and a local variable in the Parse function. Only a local variable is initialized with something.
It is not clear to me where exactly and what exactly you are looking at in the debugger, but most likely the error is that you are looking in the wrong place.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question