# 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

enum kyotocabinet::Regex::Option

Options.

Enumerator:

  IGNCASE | case-insensitive
  MATCHONLY | matching only

## Constructor & Destructor Documentation

kyotocabinet::Regex::Regex | ( |  | ) | `[explicit]`

Default constructor.

kyotocabinet::Regex::~Regex | ( |  | ) |

Destructor.

## Member Function Documentation

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

Compile a string of regular expression.

Parameters:

  regex | the string of regular expression.
  opts | the 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:

  str | the 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:

  str | the string.
  alt | the 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:

  str | the string.
  pattern | the matching pattern.
  opts | the 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:

  str | the string.
  pattern | the matching pattern.
  alt | the 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.
  opts | the optional features by bitwise-or: Regex::IGNCASE for case-insensitive matching, Regex::MATCHONLY for matching only usage.

Returns:
  the result string.