wex v24.10.0
Public Types | Public Member Functions | List of all members
wex::regex_part Class Reference

This class offers partial regular expression matching, as supported by the boost regex classes. More...

#include <wex/core/regex-part.h>

Public Types

enum class  match_t {
  NONE , ERRORS , PART , HISTORY ,
  FULL
}
 The match types. More...
 

Public Member Functions

 regex_part (const std::string &regex, boost::regex::flag_type flags=boost::regex::ECMAScript)
 Constructor.
 
const std::string & error () const
 Returns the error (in case match_t::ERRORS).
 
match_t match (char c)
 Regular expression match using a single char at a time, possibly continuing a previous match.
 
match_t match_type () const
 Returns the match type.
 
const std::string & regex () const
 Returns the regex.
 
void reset ()
 Resets matching to start again.
 
const std::string & text () const
 Returns the current text (all chars that matched).
 

Detailed Description

This class offers partial regular expression matching, as supported by the boost regex classes.

For example a regex: *+ Settings *+ and incomplete text '* Set' would not match a normal std::regex, this class matches all *, * , * Set, * Settings *, where the first 3 would return a match_t::PART, and the last a match_t::FULL.

Member Enumeration Documentation

◆ match_t

enum class wex::regex_part::match_t
strong

The match types.

Enumerator
NONE 

the current text does not match at all, even partly

ERRORS 

the regex part gives a regex error during parsing

PART 

the current text matches part of regex part

HISTORY 

the current text matches part of regex part, last char not

FULL 

the current text matches all regex part

Constructor & Destructor Documentation

◆ regex_part()

wex::regex_part::regex_part ( const std::string & regex,
boost::regex::flag_type flags = boost::regex::ECMAScript )
inline

Constructor.

Parameters
regexthe regular expression string
flagsthe regex flags

Member Function Documentation

◆ match()

wex::regex_part::match_t wex::regex_part::match ( char c)
inline

Regular expression match using a single char at a time, possibly continuing a previous match.

Returns the match_t:

  • PART: The resulting text from this and all previous chars do match
  • FULL: The text matches the complete regex
  • NONE: There is no match
  • ERRORS: There is a regex error, available using error() Non ascii chars are ignored.