Skip to content
Snippets Groups Projects
Commit f1aeb454 authored by Stéphane Poirier's avatar Stéphane Poirier
Browse files

[Regex] some ready-to-use patterns in Regex::Pattern: number, dec_octet, ipv4_addr

parent 3d692cba
No related branches found
No related tags found
No related merge requests found
......@@ -134,6 +134,7 @@
namespace yat
{
// ============================================================================
//! \class Regex
//! \brief Wrapper over the GNU Regular expression processor
......@@ -147,6 +148,14 @@ class YAT_DECL Regex
{
public:
//! Some basic patterns
struct Pattern
{
static const String number; //! real number with or without exposant
static const String dec_octet; //! decimal octet (integer number in [0-255])
static const String ipv4_addr; //! ipv4 address (dec_octet.dec_octer.dec_octet.dec_octet)
};
enum CompFlags
{
basic = 1,
......
......@@ -67,6 +67,12 @@ typedef YAT_WEAK_PTR(::regex_t) CompiledRegexWPtr;
Mutex Regex::s_mtx;
#endif
const std::string _DEC_OCTET = "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])";
const String Regex::Pattern::number = R"([\+\-]?([0-9]+|\.[0-9]+|[0-9]+\.|[0-9]+\.[0-9]+)([eE][\+\-]?[0-9]+)?)";
const String Regex::Pattern::dec_octet = _DEC_OCTET;
const String Regex::Pattern::ipv4_addr = _DEC_OCTET + R"(\.)" + _DEC_OCTET + R"(\.)" + _DEC_OCTET + R"(\.)" + _DEC_OCTET;
// ============================================================================
// class RegexCache
// Simple FIFO cache
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment