Kyoto Cabinet
Public Types | Public Member Functions | Static Public Member Functions
kyotocabinet::Regex Class Reference

Regular expression. More...

#include <kcregex.h>

List of all members.

Public Types

enum  Option { IGNCASE = 1 << 0, MATCHONLY = 1 << 1 }
 Options. More...

Public Member Functions

 Regex ()
 Default constructor.
 ~Regex ()
 Destructor.
bool compile (const std::string &regex, uint32_t opts=0)
 Compile a string of regular expression.
bool match (const std::string &str)
 Check whether a string matches the regular expression.
std::string replace (const std::string &str, const std::string &alt)
 Check whether a string matches the regular expression.

Static Public Member Functions

static bool match (const std::string &str, const std::string &pattern, uint32_t opts=0)
 Check whether a string matches a regular expression.
static std::string replace (const std::string &str, const std::string &pattern, const std::string &alt, uint32_t opts=0)
 Check whether a string matches the regular expression.

Detailed Description

Regular expression.


Member Enumeration Documentation

Options.

Enumerator:
IGNCASE 

case-insensitive

MATCHONLY 

matching only


Constructor & Destructor Documentation

Default constructor.

Destructor.


Member Function Documentation

bool kyotocabinet::Regex::compile ( const std::string &  regex,
uint32_t  opts = 0 
)

Compile a string of regular expression.

Parameters:
regexthe string of regular expression.
optsthe optional features by bitwise-or: Regex::IGNCASE for case-insensitive matching, Regex::MATCHONLY for matching only usage.
bool kyotocabinet::Regex::match ( const std::string &  str)

Check whether a string matches the regular expression.

Parameters:
strthe string.
Returns:
true if the string matches, or false if not.
std::string kyotocabinet::Regex::replace ( const std::string &  str,
const std::string &  alt 
)

Check whether a string matches the regular expression.

Parameters:
strthe string.
altthe alternative string with which each substring is replaced. Each "$" in the string escapes the following character. Special escapes "$1" through "$9" refer to partial substrings corresponding to sub-expressions in the regular expression. "$0" and "$&" refer to the whole matching substring.
Returns:
the result string.
static bool kyotocabinet::Regex::match ( const std::string &  str,
const std::string &  pattern,
uint32_t  opts = 0 
) [static]

Check whether a string matches a regular expression.

Parameters:
strthe string.
patternthe matching pattern.
optsthe optional features by bitwise-or: Regex::IGNCASE for case-insensitive matching, Regex::MATCHONLY for matching only usage.
Returns:
true if the string matches, or false if not.
static std::string kyotocabinet::Regex::replace ( const std::string &  str,
const std::string &  pattern,
const std::string &  alt,
uint32_t  opts = 0 
) [static]

Check whether a string matches the regular expression.

Parameters:
strthe string.
patternthe matching pattern.
altthe alternative string with which each substring is replaced. Each "$" in the string escapes the following character. Special escapes "$1" through "$9" refer to partial substrings corresponding to sub-expressions in the regular expression. "$0" and "$&" refer to the whole matching substring.
optsthe optional features by bitwise-or: Regex::IGNCASE for case-insensitive matching, Regex::MATCHONLY for matching only usage.
Returns:
the result string.