Doxygen
reg 命名空间参考

Namespace for the regular expression functions 更多...

class  Ex
 Class representing a regular expression. 更多...
 
class  Iterator
 Iterator class to iterator through matches. 更多...
 
class  Match
 Object representing the matching results. 更多...
 
class  PToken
 Class representing a token in the compiled regular expression token stream. 更多...
 
class  SubMatch
 Object representing the match results of a capture range. 更多...
 

函数

static bool isspace (char c)
 
static bool isalpha (char c)
 
static bool isdigit (char c)
 
static bool isalnum (char c)
 
static std::string wildcard2regex (const std::string &pattern)
 
bool search (const std::string &str, Match &match, const Ex &re, size_t pos=0)
 Search in a given string str starting at position pos for a match against regular expression re. 更多...
 
bool search (const std::string &str, const Ex &re, size_t pos=0)
 Search in a given string str starting at position pos for a match against regular expression re. 更多...
 
bool match (const std::string &str, Match &match, const Ex &re)
 Matches a given string str for a match against regular expression re. 更多...
 
bool match (const std::string &str, const Ex &re)
 Matches a given string str for a match against regular expression re. 更多...
 
std::string replace (const std::string &str, const Ex &re, const std::string &replacement)
 Searching in a given input string for parts that match regular expression re and replaces those parts by string replacement. 更多...
 

详细描述

Namespace for the regular expression functions

函数说明

◆ isalnum()

static bool reg::isalnum ( char  c)
inlinestatic

在文件 regex.cpp48 行定义.

49 {
50  return isalpha(c) || isdigit(c);
51 }

引用了 isalpha() , 以及 isdigit().

被这些函数引用 isId(), isIdJS(), reg::Ex::Private::matchAt() , 以及 nextUTF8CharPosition().

◆ isalpha()

static bool reg::isalpha ( char  c)
inlinestatic

在文件 regex.cpp38 行定义.

39 {
40  return static_cast<unsigned char>(c)>=128 || (c>='a' && c<='z') || (c>='A' && c<='Z');
41 }

被这些函数引用 Portable::isAbsolutePath(), isalnum(), reg::Ex::Private::matchAt() , 以及 readConfiguration().

◆ isdigit()

static bool reg::isdigit ( char  c)
inlinestatic

在文件 regex.cpp43 行定义.

44 {
45  return c>='0' && c<='9';
46 }

被这些函数引用 isalnum(), reg::Ex::Private::matchAt() , 以及 nextUTF8CharPosition().

◆ isspace()

◆ match() [1/2]

bool reg::match ( const std::string &  str,
const Ex re 
)

Matches a given string str for a match against regular expression re.

Returns true iff a match was found for the whole string.

在文件 regex.cpp734 行定义.

735 {
736  Match match;
737  return re.match(str,match,0) && match.position()==0 && match.length()==str.length();
738 }

引用了 reg::Ex::match() , 以及 match().

◆ match() [2/2]

bool reg::match ( const std::string &  str,
Match match,
const Ex re 
)

◆ replace()

std::string reg::replace ( const std::string &  str,
const Ex re,
const std::string &  replacement 
)

Searching in a given input string for parts that match regular expression re and replaces those parts by string replacement.

在文件 regex.cpp740 行定义.

741 {
742  std::string result;
743  Match match;
744  size_t p=0;
745  while (re.match(str,match,p))
746  {
747  size_t i=match.position();
748  size_t l=match.length();
749  if (i>p) result+=str.substr(p,i-p);
750  result+=replacement;
751  p=i+l;
752  }
753  if (p<str.length()) result+=str.substr(p);
754  return result;
755 }

引用了 reg::Ex::match() , 以及 match().

被这些函数引用 VhdlDocGen::addBaseClass(), VHDLOutlineParser::checkInlineCode(), FileInfo::correctPath(), correctPath(), FlowChart::printNode(), replaceAnonymousScopes(), substitute() , 以及 TemplateNodeText::TemplateNodeText().

◆ search() [1/2]

bool reg::search ( const std::string &  str,
const Ex re,
size_t  pos = 0 
)

Search in a given string str starting at position pos for a match against regular expression re.

Returns true iff a match was found.

在文件 regex.cpp723 行定义.

724 {
725  Match match;
726  return re.match(str,match,pos);
727 }

引用了 reg::Ex::match() , 以及 match().

◆ search() [2/2]

bool reg::search ( const std::string &  str,
Match match,
const Ex re,
size_t  pos = 0 
)

Search in a given string str starting at position pos for a match against regular expression re.

Returns true iff a match was found. Details of what part of the string has matched is returned via the match object.

An example to show how to match all identifiers in a string.

static reg::Ex re(R"(\a\w*)");
std::string = u8"void(Func是<B_C::Códe42>(42));";
while (reg::search(str,match,re,pos))
{
std::cout << match.str() << std::endl;
pos=match.position()+match.length();
}

produces:

void
Func是
B_C
Códe42
参见
Ex::Ex() for details on the regular expression patterns.

在文件 regex.cpp718 行定义.

719 {
720  return re.match(str,match,pos);
721 }

引用了 reg::Ex::match() , 以及 match().

被这些函数引用 HtmlHelpIndex::addItem(), addVariableToFile(), VHDLOutlineParser::checkInlineCode(), MemberDefImpl::displayDefinition(), expandAliasRec(), extractTitleId(), findFunctionPtr(), findIndex(), MemberDefImpl::getClassDefOfAnonymousType(), isVarWithConstructor(), loadExtensions(), loadStylesheet(), matchExcludedSymbols(), StyleData::setStyle(), simplifyTypeForTable(), StyleData::StyleData(), MemberDefImpl::writeDeclaration() , 以及 MemberDefImpl::writeDocumentation().

◆ wildcard2regex()

static std::string reg::wildcard2regex ( const std::string &  pattern)
static

在文件 regex.cpp617 行定义.

618 {
619  std::string result="^"; // match start of input
620  char c;
621  const char *p = pattern.c_str();
622  while ((c=*p++))
623  {
624  switch(c)
625  {
626  case '*':
627  result+=".*";
628  break; // '*' => '.*'
629  case '?':
630  result+='.';
631  break; // '?' => '.'
632  case '.':
633  case '+':
634  case '\\':
635  case '$':
636  case '^':
637  case '(':
638  case ')':
639  result+='\\'; result+=c; // escape
640  break;
641  case '[':
642  if (*p=='^') // don't escape ^ after [
643  {
644  result+="[^";
645  p++;
646  }
647  else
648  {
649  result+=c;
650  }
651  break;
652  default: // just copy
653  result+=c;
654  break;
655  }
656  }
657  result+='$'; // match end of input
658  return result;
659 }

引用了 reg::Ex::p.

reg::isalpha
static bool isalpha(char c)
Definition: regex.cpp:38
reg::match
bool match(const std::string &str, Match &match, const Ex &re)
Matches a given string str for a match against regular expression re.
Definition: regex.cpp:729
reg::match
bool match(const std::string &str, const Ex &re)
Matches a given string str for a match against regular expression re.
Definition: regex.cpp:734
reg::isdigit
static bool isdigit(char c)
Definition: regex.cpp:43
reg::Ex
Class representing a regular expression.
Definition: regex.h:48
reg::search
bool search(const std::string &str, Match &match, const Ex &re, size_t pos)
Search in a given string str starting at position pos for a match against regular expression re.
Definition: regex.cpp:718