mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-02 01:33:04 +00:00
Replacing regex library with PCRE
Update build scripts
This commit is contained in:
5 files changed
+90
-27
No files matched your search
@@ -1,5 +1,5 @@
|
||||
#include <chrono>
|
||||
#include <regex>
|
||||
//#include <regex>
|
||||
#include <fstream>
|
||||
#include <thread>
|
||||
#include <sstream>
|
||||
@@ -7,6 +7,7 @@
|
||||
//#include <filesystem>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <pcrecpp.h>
|
||||
#include <rapidjson/document.h>
|
||||
#include <openssl/md5.h>
|
||||
|
||||
@@ -446,6 +447,7 @@ std::string replace_all_distinct(std::string str, std::string old_value, std::st
|
||||
return str;
|
||||
}
|
||||
|
||||
/*
|
||||
bool regValid(std::string ®)
|
||||
{
|
||||
try
|
||||
@@ -499,6 +501,65 @@ bool regMatch(std::string src, std::string match)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
bool regValid(std::string ®)
|
||||
{
|
||||
try
|
||||
{
|
||||
pcrecpp::RE r(reg);
|
||||
return true;
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool regFind(std::string src, std::string target)
|
||||
{
|
||||
try
|
||||
{
|
||||
pcrecpp::RE reg(target);
|
||||
return reg.PartialMatch(src);
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::string regReplace(std::string src, std::string match, std::string rep)
|
||||
{
|
||||
std::string result = src;
|
||||
try
|
||||
{
|
||||
if(rep.find("$") != rep.npos)
|
||||
rep = replace_all_distinct(rep, "$", "\\");
|
||||
pcrecpp::RE reg(match);
|
||||
if(TRUE == reg.Replace(rep, &result))
|
||||
return result;
|
||||
else
|
||||
return src;
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
return src;
|
||||
}
|
||||
}
|
||||
|
||||
bool regMatch(std::string src, std::string match)
|
||||
{
|
||||
try
|
||||
{
|
||||
pcrecpp::RE reg(match);
|
||||
return reg.FullMatch(src);
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::string speedCalc(double speed)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user