⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pattern.html

📁 C++正则表达式解析
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<BR><DT><B>Returns:</B><DD>  A new string containing all unique characters. Each character
must have appeared both <code>s1</code> and <code>s2</code>.<BR><DD></DL><P>
<A NAME="classNegate"></A>
<A NAME="DOC.3.17"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>std::string classNegate(std::string s1) const </B></TT>
<DD>
Calculates the negation of a string. The negation is the set of all
characters between <code>\x00</code> and <code>\xFF</code> not
contained in <code>s1</code>.

<DL><DT><DT><B>Parameters:</B><DD><B>s1</B> -  The "class" to be negated.
<BR><B>s2</B> -  The second "class" to intersect
<BR><DT><B>Returns:</B><DD>  A new string containing all unique characters. Each character
must have appeared both <code>s1</code> and <code>s2</code>.<BR><DD></DL><P>
<A NAME="classCreateRange"></A>
<A NAME="DOC.3.18"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>std::string classCreateRange(char low, char hi) const </B></TT>
<DD>
Creates a new "class" representing the range from <code>low</code> thru
<code>hi</code>. This function will wrap if <code>low</code> &gt;
<code>hi</code>. This is a feature, not a buf. Sometimes it is useful
to be able to say [\x70-\x10] instead of [\x70-\x7F\x00-\x10].

<DL><DT><DT><B>Parameters:</B><DD><B>low</B> -  The beginning character
<BR><B>hi</B> -   The ending character
<BR><DT><B>Returns:</B><DD>  A new string containing all the characters from low thru hi.<BR><DD></DL><P>
<A NAME="getInt"></A>
<A NAME="DOC.3.19"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>int getInt(int <!1><A HREF="Matcher.html#DOC.2.4">start</A>, int end)</B></TT>
<DD>
Extracts a decimal number from the substring of member-variable
<code><!1><A HREF="Pattern.html#DOC.3.7">pattern</A><code> starting at <code>start</code> and
ending at <code>end</code>.

<DL><DT><DT><B>Parameters:</B><DD><B></B> - <!1><A HREF="Matcher.html#DOC.2.4">start</A> The starting index in <code><!1><A HREF="Pattern.html#DOC.3.7">pattern</A><code>
<BR><B>end</B> -  The last index in <code><!1><A HREF="Pattern.html#DOC.3.7">pattern</A><code>
<BR><DT><B>Returns:</B><DD>  The decimal number in <code><!1><A HREF="Pattern.html#DOC.3.7">pattern</A><code><BR><DD></DL><P>
<A NAME="quantifyCurly"></A>
<A NAME="DOC.3.20"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>bool quantifyCurly(int &amp; sNum, int &amp; eNum)</B></TT>
<DD>
Parses a <code>{n,m}</code> string out of the member-variable
<code><!1><A HREF="Pattern.html#DOC.3.7">pattern</A><code> stores the result in <code>sNum</code>
and <code>eNum</code>.

<DL><DT><DT><B>Parameters:</B><DD><B>sNum</B> -  Output parameter. The minimum number of <!1><A HREF="Pattern.html#DOC.3.45">matches</A> required
by the curly quantifier are stored here.
<BR><B>eNum</B> -  Output parameter. The maximum number of <!1><A HREF="Pattern.html#DOC.3.45">matches</A> allowed
by the curly quantifier are stored here.
<BR><DT><B>Returns:</B><DD>  Success/Failure. Fails when the curly does not have the proper
syntax<BR><DD></DL><P>
<A NAME="quantifyGroup"></A>
<A NAME="DOC.3.21"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>NFANode* quantifyGroup(NFANode*  <!1><A HREF="Matcher.html#DOC.2.4">start</A>, NFANode*  stop, const int gn)</B></TT>
<DD>
Tries to quantify the currently parsed group. If the group being parsed
is indeed quantified in the member-variable
<code><!1><A HREF="Pattern.html#DOC.3.7">pattern</A><code>, then the NFA is modified accordingly.

<DL><DT><DT><B>Parameters:</B><DD><B></B> - <!1><A HREF="Matcher.html#DOC.2.4">start</A>  The starting node of the current group being parsed
<BR><B>stop</B> -    The ending node of the current group being parsed
<BR><B>gn</B> -      The group number of the current group being parsed
<BR><DT><B>Returns:</B><DD>  The node representing the starting node of the group. If the
group becomes quantified, then this node is not necessarily
a GroupHead node.<BR><DD></DL><P>
<A NAME="quantify"></A>
<A NAME="DOC.3.22"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>NFANode* quantify(NFANode*  newNode)</B></TT>
<DD>
Tries to quantify the last parsed expression. If the character was indeed
quantified, then the NFA is modified accordingly.

<DL><DT><DT><B>Parameters:</B><DD><B>newNode</B> -  The recently created expression node
<BR><DT><B>Returns:</B><DD>  The node representing the last parsed expression. If the
expression was quantified, <code>return value != newNode</code><BR><DD></DL><P>
<A NAME="parseClass"></A>
<A NAME="DOC.3.23"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>std::string parseClass()</B></TT>
<DD>
Parses the current class being examined in
<code><!1><A HREF="Pattern.html#DOC.3.7">pattern</A></code>.

<DL><DT><DT><B>Returns:</B><DD>  A string of unique characters contained in the current class being
parsed<BR><DD></DL><P>
<A NAME="parsePosix"></A>
<A NAME="DOC.3.24"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>std::string parsePosix()</B></TT>
<DD>
Parses the current POSIX class being examined in
<code><!1><A HREF="Pattern.html#DOC.3.7">pattern</A></code>.

<DL><DT><DT><B>Returns:</B><DD>  A string of unique characters representing the POSIX class being
parsed<BR><DD></DL><P>
<A NAME="parseOctal"></A>
<A NAME="DOC.3.25"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>std::string parseOctal()</B></TT>
<DD>
Returns a string containing the octal character being parsed

<DL><DT><DT><B>Returns:</B><DD>  The string contained the octal value being parsed<BR><DD></DL><P>
<A NAME="parseHex"></A>
<A NAME="DOC.3.26"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>std::string parseHex()</B></TT>
<DD>
Returns a string containing the hex character being parsed

<DL><DT><DT><B>Returns:</B><DD>  The string contained the hex value being parsed<BR><DD></DL><P>
<A NAME="parseBackref"></A>
<A NAME="DOC.3.27"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>NFANode* parseBackref()</B></TT>
<DD>
Returns a new node representing the back reference being parsed

<DL><DT><DT><B>Returns:</B><DD>  The new node representing the back reference being parsed<BR><DD></DL><P>
<A NAME="parseEscape"></A>
<A NAME="DOC.3.28"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>std::string parseEscape(bool &amp; inv, bool &amp; quo)</B></TT>
<DD>
Parses the escape sequence currently being examined. Determines if the
escape sequence is a class, a single character, or the beginning of a
quotation sequence.

<DL><DT><DT><B>Parameters:</B><DD><B>inv</B> -  Output parameter. Whether or not to invert the returned class
<BR><B>quo</B> -  Output parameter. Whether or not this sequence <!1><A HREF="Matcher.html#DOC.2.5">starts</A> a
quotation.
<BR><DT><B>Returns:</B><DD>  The characters represented by the class<BR><DD></DL><P>
<A NAME="parseRegisteredPattern"></A>
<A NAME="DOC.3.29"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>NFANode* parseRegisteredPattern(NFANode**  end)</B></TT>
<DD>
Parses a supposed registered pattern currently under compilation. If the
sequence of characters does point to a registered pattern, then the
registered pattern is appended to <code>*end<code>. The registered pattern
is parsed with the current compilation flags.

<DL><DT><DT><B>Parameters:</B><DD><B>end</B> -  The ending node of the thus-far compiled <!1><A HREF="Pattern.html#DOC.3.7">pattern</A>
<BR><DT><B>Returns:</B><DD>  The new end node of the current pattern<BR><DD></DL><P>
<A NAME="parseBehind"></A>
<A NAME="DOC.3.30"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>NFANode* parseBehind(const bool pos, NFANode**  end)</B></TT>
<DD>
Parses a lookbehind expression. Appends the necessary nodes
<code>*end</code>.

<DL><DT><DT><B>Parameters:</B><DD><B>pos</B> -  Positive or negative look behind
<BR><B>end</B> -  The ending node of the current <!1><A HREF="Pattern.html#DOC.3.7">pattern</A>
<BR><DT><B>Returns:</B><DD>  The new end node of the current pattern<BR><DD></DL><P>
<A NAME="parseQuote"></A>
<A NAME="DOC.3.31"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>NFANode* parseQuote()</B></TT>
<DD>
Parses the current expression and tacks on nodes until a \E is found.

<DL><DT><DT><B>Returns:</B><DD>  The end of the current pattern<BR><DD></DL><P>
<A NAME="parse"></A>
<A NAME="DOC.3.32"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>NFANode* parse(const bool inParen = 0, const bool inOr = 0, NFANode**  end = NULL)</B></TT>
<DD>
Parses <code><!1><A HREF="Pattern.html#DOC.3.7">pattern</A></code>. This function is called
recursively when an or (<code>|</code>) or a group is encountered.

<DL><DT><DT><B>Parameters:</B><DD><B>inParen</B> -  Are we currently parsing inside a group
<BR><B>inOr</B> -  Are we currently parsing one side of an or (<code>|</code>)
<BR><B>end</B> -  The end of the current expression
<BR><DT><B>Returns:</B><DD>  The starting node of the NFA constructed from this parse<BR><DD></DL><P>
<A NAME="CASE_INSENSITIVE"></A>
<A NAME="DOC.3.33"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>static  const unsigned long CASE_INSENSITIVE</B></TT>
<DD>We should match regardless of case
<DL><DT><DD></DL><P>
<A NAME="LITERAL"></A>
<A NAME="DOC.3.34"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>static  const unsigned long LITERAL</B></TT>
<DD>We are implicitly quoted
<DL><DT><DD></DL><P>
<A NAME="DOT_MATCHES_ALL"></A>
<A NAME="DOC.3.35"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>static  const unsigned long DOT_MATCHES_ALL</B></TT>
<DD>We should treat a <code><b>.</b></code> as [\x00-\x7F]
<DL><DT><DD></DL><P>
<A NAME="MULTILINE_MATCHING"></A>
<A NAME="DOC.3.36"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>static  const unsigned long MULTILINE_MATCHING</B></TT>
<DD><code>^</code> and <code>$</code> should anchor to the beginning and
ending of lines, not all input
<DL><DT><DD></DL><P>
<A NAME="UNIX_LINE_MODE"></A>
<A NAME="DOC.3.37"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>static  const unsigned long UNIX_LINE_MODE</B></TT>
<DD>When enabled, only instances of <code>\n</codes> are recognized as
line terminators
<DL><DT><DD></DL><P>
<A NAME="MIN_QMATCH"></A>
<A NAME="DOC.3.38"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>static  const int MIN_QMATCH</B></TT>
<DD>The absolute minimum number of matches a quantifier can match (0)
<DL><DT><DD></DL><P>
<A NAME="MAX_QMATCH"></A>
<A NAME="DOC.3.39"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>static  const int MAX_QMATCH</B></TT>
<DD>The absolute maximum number of matches a quantifier can match (0x7FFFFFFF)
<DL><DT><DD></DL><P>
<A NAME="compile"></A>
<A NAME="DOC.3.40"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>static   <!1><A HREF="Pattern.html">Pattern</A>* compile(const std::string &amp; <!1><A HREF="Pattern.html#DOC.3.7">pattern</A>, const unsigned long mode = 0)</B></TT>
<DD>
Call this function to compile a regular expression into a
<code>Pattern</code> object. Special values can be assigned to
<code>mode</code> when certain non-standard behaviors are expected from
the <code>Pattern</code> object.

<DL><DT><DT><B>Parameters:</B><DD><B></B> - <!1><A HREF="Pattern.html#DOC.3.7">pattern</A> The regular expression to <!1><A HREF="Pattern.html#DOC.3.40">compile</A>
<BR><B>mode</B> -     A bitwise or of <!1><A HREF="Pattern.html#DOC.3.12">flags</A> signalling what special behaviors are
wanted from this <code><!1><A HREF="Pattern.html">Pattern</A></code> object
<BR><DT><B>Returns:</B><DD>  If successful, <code>compile</code> returns a <code>Pattern</code>
pointer. Upon failure, <code>compile</code> returns
<code>NULL</code><BR><DD></DL><P>
<A NAME="compileAndKeep"></A>
<A NAME="DOC.3.41"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>static   <!1><A HREF="Pattern.html">Pattern</A>* compileAndKeep(const std::string &amp; <!1><A HREF="Pattern.html#DOC.3.7">pattern</A>, const unsigned long mode = 0)</B></TT>
<DD>
Dont use this function. This function will compile a pattern, and cache
the result. This will eventually be used as an optimization when people
just want to call static methods using the same pattern over and over
instead of first compiling the pattern and then using the compiled
instance for matching.

<DL><DT><DT><B>Parameters:</B><DD><B></B> - <!1><A HREF="Pattern.html#DOC.3.7">pattern</A> The regular expression to <!1><A HREF="Pattern.html#DOC.3.40">compile</A>
<BR><B>mode</B> -     A bitwise or of <!1><A HREF="Pattern.html#DOC.3.12">flags</A> signalling what special behaviors are
wanted from this <code><!1><A HREF="Pattern.html">Pattern</A></code> object
<BR><DT><B>Returns:</B><DD>  If successful, <code>compileAndKeep</code> returns a
<code>Pattern</code> pointer. Upon failure, <code>compile</code>
returns <code>NULL</code>.<BR><DD></DL><P>
<A NAME="replace"></A>
<A NAME="DOC.3.42"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>static   std::string replace(const std::string &amp; <!1><A HREF="Pattern.html#DOC.3.7">pattern</A>, const std::string &amp; <!1><A HREF="Pattern.html#DOC.3.42">replace</A>, const std::string &amp; <!1><A HREF="Matcher.html#DOC.2.3">str</A>, const unsigned long mode = 0)</B></TT>
<DD>
Searches through <code>replace</code> and replaces all substrings matched
by <code>pattern</code> with <code>str</code>. <code>str</code> may
contain backreferences (e.g. <code>\1</code>) to capture groups. A typical
invocation looks like:
<p>
<code>
Pattern::replace("(a+)b(c+)", "abcccbbabcbabc", "\\2b\\1");
</code>
<p>
which would replace <code>abcccbbabcbabc</code> with
<code>cccbabbcbabcba</code>.

<DL><DT><DT><B>Parameters:</B><DD><B></B> - <!1><A HREF="Pattern.html#DOC.3.7">pattern</A>  The regular expression
<BR><B></B> - <!1><A HREF="Pattern.html#DOC.3.42">replace</A>  The string in which to perform replacements
<BR><B></B> - <!1><A HREF="Matcher.html#DOC.2.3">str</A>      The replacement text
<BR><B>mode</B> -      The special mode requested of the <code><!1><A HREF="Pattern.html">Pattern</A></code>
during the replacement process
<BR><DT><B>Returns:</B><DD>  The text with the replacement string substituted where necessary<BR><DD></DL><P>
<A NAME="split"></A>
<A NAME="DOC.3.43"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>static   std::vector&lt;std::string&gt;  split(const std::string &amp; <!1><A HREF="Pattern.html#DOC.3.7">pattern</A>, const std::string &amp; <!1><A HREF="Matcher.html#DOC.2.3">str</A>, const bool keepEmptys = 0, const unsigned long limit = 0, const unsigned long mode = 0)</B></TT>
<DD>
Splits the specified string over occurrences of the specified pattern.
Empty strings can be optionally ignored. The number of strings returned is
configurable. A typical invocation looks like:
<p>
<code>
std::string str(strSize, '\0');<br>
FILE * fp = fopen(fileName, "r");<br>
fread((char*)str.data(), strSize, 1, fp);<br>
fclose(fp);<br>
<br>
std::vector&lt;std::string&gt; lines = Pattern::split("[\r\n]+", str, true);<br>
<br>
</code>

<P>
<DL><DT><DT><B>Parameters:</B><DD><B></B> - <!1><A HREF="Pattern.html#DOC.3.7">pattern</A>    The regular expression
<BR><B></B> - <!1><A HREF="Pattern.html#DOC.3.42">replace</A>    The string to <!1><A HREF="Pattern.html#DOC.3.43">split</A>
<BR><B>keepEmptys</B> -  Whether or not to keep empty strings
<BR><B>limit</B> -       The maximum number of splits to make
<BR><B>mode</B> -        The special mode requested of the <code><!1><A HREF="Pattern.html">Pattern</A></code>
during the <!1><A HREF="Pattern.html#DOC.3.43">split</A> process
<BR><DT><B>Returns:</B><DD>  All substrings of <code>str</code> split across <code>pattern</code>.<BR><DD></DL><P>
<A NAME="findAll"></A>
<A NAME="DOC.3.44"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>static   std::vector&lt;std::string&gt;  findAll(const std::string &amp; <!1><A HREF="Pattern.html#DOC.3.7">pattern</A>, const std::string &amp; <!1><A HREF="Matcher.html#DOC.2.3">str</A>, const unsigned long mode = 0)</B></TT>
<DD>
Finds all the instances of the specified pattern within the string. You
should be careful to only pass patterns with a minimum length of one. For
example, the pattern <code>a*</code> can be matched by an empty string, so
instead you should pass <code>a+</code> since at least one character must
be matched. A typical invocation of <code>findAll</code> looks like:
<p>
<code>
std::vector&lt;td::string&gt; numbers = Pattern::findAll("\\d+", string);
</code>
<p>

<P>
<DL><DT><DT><B>Parameters:</B><DD><B></B> - <!1><A HREF="Pattern.html#DOC.3.7">pattern</A>  The <!1><A HREF="Pattern.html#DOC.3.7">pattern</A> for which to search
<BR><B></B> - <!1><A HREF="Matcher.html#DOC.2.3">str</A>      The string to search
<BR><B>mode</B> -      The special mode requested of the <code><!1><A HREF="Pattern.html">Pattern</A></code>
during the find process
<BR><DT><B>Returns:</B><DD>  All instances of <code>pattern</code> in <code>str</code><BR><DD></DL><P>
<A NAME="matches"></A>
<A NAME="DOC.3.45"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>static   bool matches(const std::string &amp; <!1><A HREF="Pattern.html#DOC.3.7">pattern</A>, const std::string &amp; <!1><A HREF="Matcher.html#DOC.2.3">str</A>, const unsigned long mode = 0)</B></TT>
<DD>
Determines if an entire string matches the specified pattern

<P>
<DL><DT><DT><B>Parameters:</B><DD><B></B> - <!1><A HREF="Pattern.html#DOC.3.7">pattern</A>  The <!1><A HREF="Pattern.html#DOC.3.7">pattern</A> for to match
<BR><B></B> - <!1><A HREF="Matcher.html#DOC.2.3">str</A>      The string to match
<BR><B>mode</B> -      The special mode requested of the <code><!1><A HREF="Pattern.html">Pattern</A></code>
during the replacement process
<BR><DT><B>Returns:</B><DD>  True if <code>str</code> is recognized by <code>pattern</code><BR><DD></DL><P>
<A NAME="registerPattern"></A>
<A NAME="DOC.3.46"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>static   bool registerPattern(const std::string &amp; name, const std::string &amp; <!1><A HREF="Pattern.html#DOC.3.7">pattern</A>, const unsigned long mode = 0)</B></TT>
<DD>
Registers a pattern under a specific name for use in later compilations.
A typical invocation and later use looks like:
<p>
<code>
Pattern::registerPattern("ip", "(?:\\d{1,3}\\.){3}\\d{1,3}");<br>
Pattern * p1 = Pattern::compile("{ip}:\\d+");<br>
Pattern * p2 = Pattern::compile("Connection from ({ip}) on port \\d+");<br>
</code>
<p>
Multiple calls to <code>registerPattern</code> with the same
<code>name</code> will result in the pattern getting overwritten.

<P>
<DL><DT><DT><B>Parameters:</B><DD><B>name</B> -      The name to give to the <!1><A HREF="Pattern.html#DOC.3.7">pattern</A>
<BR><B></B> - <!1><A HREF="Pattern.html#DOC.3.7">pattern</A>  The <!1><A HREF="Pattern.html#DOC.3.7">pattern</A> to register
<BR><B>mode</B> -      Any special <!1><A HREF="Pattern.html#DOC.3.12">flags</A> to use when compiling <!1><A HREF="Pattern.html#DOC.3.7">pattern</A>
<BR><DT><B>Returns:</B><DD>  Success/Failure. Fails only if <code>pattern</code> has invalid
syntax<BR><DD></DL><P>
<A NAME="unregisterPatterns"></A>
<A NAME="DOC.3.47"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>static   void unregisterPatterns()</B></TT>
<DD>
Clears the pattern registry
<DL><DT><DD></DL><P>
<A NAME="clearPatternCache"></A>
<A NAME="DOC.3.48"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>static   void clearPatternCache()</B></TT>
<DD>
Don't use
<DL><DT><DD></DL><P>
<A NAME="findNthMatch"></A>
<A NAME="DOC.3.49"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>static   std::pair&lt;std::string, int&gt;  findNthMatch(const std::string &amp; <!1><A HREF="Pattern.html#DOC.3.7">pattern</A>, const std::string &amp; <!1><A HREF="Matcher.html#DOC.2.3">str</A>, const int matchNum, const unsigned long mode = 0)</B></TT>
<DD>
Searches through a string for the <code>n<sup>th</sup></code> match of the
given pattern in the string. Match indeces start at zero, not one.
A typical invocation looks like this:
<p>
<code>
std::pair&lt;std::string, int&gt; match = Pattern::findNthMatch("\\d{1,3}", "192.168.1.101:22", 1);<br>
printf("%s %i\n", match.first.c_str(), match.second);<br>
<br>
Output: 168 4<br>
<br>

<P>
<DL><DT><DT><B>Parameters:</B><DD><B></B> - <!1><A HREF="Pattern.html#DOC.3.7">pattern</A>  The <!1><A HREF="Pattern.html#DOC.3.7">pattern</A> for which to search
<BR><B></B> - <!1><A HREF="Matcher.html#DOC.2.3">str</A>      The string to search
<BR><B>matchNum</B> -  Which match to find
<BR><B>mode</B> -      Any special <!1><A HREF="Pattern.html#DOC.3.12">flags</A> to use during the matching process
<BR><DT><B>Returns:</B><DD>  A string and an integer. The string is the string matched. The
integer is the starting location of the matched string in
<code>str</code>. You can check for success/failure by making sure
that the integer returned is greater than or equal to zero.<BR><DD></DL><P>
<A NAME="~Pattern"></A>
<A NAME="DOC.3.50"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B> ~Pattern()</B></TT>
<DD>
Deletes all NFA nodes allocated during compilation
<DL><DT><DD></DL><P>
<A NAME="getFlags"></A>
<A NAME="DOC.3.51"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>unsigned long getFlags() const </B></TT>
<DD>
Returns the flags used during compilation of this pattern

<DL><DT><DT><B>Returns:</B><DD>  The flags used during compilation of this pattern<BR><DD></DL><P>
<A NAME="getPattern"></A>
<A NAME="DOC.3.52"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>std::string getPattern() const </B></TT>
<DD>
Returns the regular expression this pattern represents

<DL><DT><DT><B>Returns:</B><DD>  The regular expression this pattern represents<BR><DD></DL><P>
<A NAME="createMatcher"></A>
<A NAME="DOC.3.53"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B><!1><A HREF="Matcher.html">Matcher</A>* createMatcher(const std::string &amp; <!1><A HREF="Matcher.html#DOC.2.3">str</A>)</B></TT>
<DD>
Creates a matcher object using the specified string and this pattern.

<DL><DT><DT><B>Parameters:</B><DD><B></B> - <!1><A HREF="Matcher.html#DOC.2.3">str</A> The string to match against
<BR><DT><B>Returns:</B><DD>  A new matcher using object using this pattern and the specified
string<BR><DD></DL><P></DL>

<HR><DL><DT><B>This class has no child classes.</B></DL>

<DL><DT><DT><B>Friends:</B><DD>  class <!1><A HREF="Matcher.html">Matcher</A><BR>  class NFANode<BR>  class NFAQuantifierNode<BR><DT><B>Author:</B><DD>Jeffery Stuart

<DT><B>Version:</B><DD>0.01a

<DT><B>Since:</B><DD>March 2003, Stable Since November 2004

<DD></DL><P><P><I><A HREF="index.html">Alphabetic index</A></I> <I><A HREF="HIER.html">HTML hierarchy of classes</A> or <A HREF="HIERjava.html">Java</A></I></P><HR>
<BR>
This page was generated with the help of <A HREF="http://docpp.sourceforge.net">DOC++</A>.
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -