mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-02 01:33:04 +00:00
Fix compile error with USE_STD_REGEX
Issue [#74](https://github.com/tindy2013/subconverter/issues/74).
This commit is contained in:
1 parent
0eaec3a162
commit
8fe8dcbe86
1 file changed
+9
-6
+9
-6
@@ -521,12 +521,13 @@ bool regValid(const std::string ®)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool regFind(const std::string &src, const std::string &target)
|
bool regFind(const std::string &src, const std::string &match)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::regex::flag_type flags = std::regex::extended | std::regex::ECMAScript;
|
std::regex::flag_type flags = std::regex::extended | std::regex::ECMAScript;
|
||||||
if(target.find("(?i)") == 0)
|
std::string target = match;
|
||||||
|
if(match.find("(?i)") == 0)
|
||||||
{
|
{
|
||||||
target.erase(0, 4);
|
target.erase(0, 4);
|
||||||
flags |= std::regex::icase;
|
flags |= std::regex::icase;
|
||||||
@@ -546,12 +547,13 @@ std::string regReplace(const std::string &src, const std::string &match, const s
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::regex::flag_type flags = std::regex::extended | std::regex::ECMAScript;
|
std::regex::flag_type flags = std::regex::extended | std::regex::ECMAScript;
|
||||||
|
std::string target = match;
|
||||||
if(match.find("(?i)") == 0)
|
if(match.find("(?i)") == 0)
|
||||||
{
|
{
|
||||||
match.erase(0, 4);
|
target.erase(0, 4);
|
||||||
flags |= std::regex::icase;
|
flags |= std::regex::icase;
|
||||||
}
|
}
|
||||||
std::regex reg(match, flags);
|
std::regex reg(target, flags);
|
||||||
regex_replace(back_inserter(result), src.begin(), src.end(), reg, rep);
|
regex_replace(back_inserter(result), src.begin(), src.end(), reg, rep);
|
||||||
}
|
}
|
||||||
catch (std::regex_error &e)
|
catch (std::regex_error &e)
|
||||||
@@ -566,12 +568,13 @@ bool regMatch(const std::string &src, const std::string &match)
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::regex::flag_type flags = std::regex::extended | std::regex::ECMAScript;
|
std::regex::flag_type flags = std::regex::extended | std::regex::ECMAScript;
|
||||||
|
std::string target = match;
|
||||||
if(match.find("(?i)") == 0)
|
if(match.find("(?i)") == 0)
|
||||||
{
|
{
|
||||||
match.erase(0, 4);
|
target.erase(0, 4);
|
||||||
flags |= std::regex::icase;
|
flags |= std::regex::icase;
|
||||||
}
|
}
|
||||||
std::regex reg(match, flags);
|
std::regex reg(target, flags);
|
||||||
return regex_match(src, reg);
|
return regex_match(src, reg);
|
||||||
}
|
}
|
||||||
catch (std::regex_error &e)
|
catch (std::regex_error &e)
|
||||||
|
|||||||
Reference in new issue
Block a user