|
Source-highlight Library
|
preprocess a regular expression, e.g., transform "()" into "(?:)" More...
#include <regexpreprocessor.h>
Static Public Member Functions | |
| static const std::string | replace_references (const std::string &original, const backreference_replacements &replace) |
| Replace into the original string occurrences of backreferences with the corresponding string in the replace parameter, i.e., n} backreference will be replaced with replace[n-1]. | |
| static const std::string | replace_references (const std::string &original, const regex_match_results &results) |
| Replace into the original string occurrences of backreferences with the corresponding subexpressions that matched in the results. | |
| static const std::string | preprocess (const std::string &s) |
| translates marked subexpressions (...) into non marked subexpressions (?: ) | |
| static const std::string | make_nonsensitive (const std::string &s) |
| translates the expression into a case nonsensitive expression, i.e., foo is translated into [Ff][Oo][Oo] | |
| static unsigned int | num_of_subexpressions (const std::string &s) |
| counts the number of marked subexpressions (...) | |
| static subexpressions_info | num_of_marked_subexpressions (const std::string &s, bool allow_outer_char=false, bool allow_outer_nonmarked=false) |
| check that the expressions is made up of marked subexpressions (...) and no nested subexpressions and no char outside subexpressions (unless allow_outer_char is true). | |
| static const subexpressions_strings * | split_marked_subexpressions (const std::string &s) |
| Splits the marked subexpressions of a regular expression made up of only marked subexpressions and no nested subexpressions and char outside subexpressions (thus, before calling this, you must make sure that num_of_marked_subexpressions did not return an error. | |
| static bool | contains_backreferences (const std::string &s) |
| Checks whether the passed regular expression string contains a backreference (e.g., either \1 or a conditional with a backreference (?(1)...) | |
| static backreference_info | num_of_backreferences (const std::string &s) |
| counts the number of backreferences (also in conditionals) | |
| static backreference_info | num_of_references (const std::string &s) |
| counts the number of references (i.e., reference to a matched subexpression of another regular expression) | |
| static const std::string | replace_backreferences (const std::string &original, const backreference_replacements &replace) |
| Replace into the original string occurrences of backreferences with the corresponding string in the replace parameter, i.e., backreference will be replaced with replace[n-1]. | |
| static const std::string | replace_backreferences (const std::string &original, const regex_match_results &results) |
| Replace into the original string occurrences of backreferences with the corresponding subexpressions that matched in the results. | |
preprocess a regular expression, e.g., transform "()" into "(?:)"
| bool srchilite::RegexPreProcessor::contains_backreferences | ( | const std::string & | s | ) | [static] |
Checks whether the passed regular expression string contains a backreference (e.g., either \1 or a conditional with a backreference (?(1)...)
| const string srchilite::RegexPreProcessor::make_nonsensitive | ( | const std::string & | s | ) | [static] |
translates the expression into a case nonsensitive expression, i.e., foo is translated into [Ff][Oo][Oo]
| backreference_info srchilite::RegexPreProcessor::num_of_backreferences | ( | const std::string & | s | ) | [static] |
counts the number of backreferences (also in conditionals)
| s |
| subexpressions_info srchilite::RegexPreProcessor::num_of_marked_subexpressions | ( | const std::string & | s, |
| bool | allow_outer_char = false, |
||
| bool | allow_outer_nonmarked = false |
||
| ) | [static] |
check that the expressions is made up of marked subexpressions (...) and no nested subexpressions and no char outside subexpressions (unless allow_outer_char is true).
Non-marked groups are allowed only if allow_outer_nonmarked is true.
| s | |
| allow_outer_char | whether we allow characters outside marked subexps |
| allow_outer_nonmarked | whether we allow outer nonmarked subexps |
| backreference_info srchilite::RegexPreProcessor::num_of_references | ( | const std::string & | s | ) | [static] |
counts the number of references (i.e., reference to a matched subexpression of another regular expression)
| s |
| unsigned int srchilite::RegexPreProcessor::num_of_subexpressions | ( | const std::string & | s | ) | [static] |
counts the number of marked subexpressions (...)
| s |
| const string srchilite::RegexPreProcessor::preprocess | ( | const std::string & | s | ) | [static] |
translates marked subexpressions (...) into non marked subexpressions (?: )
| const std::string srchilite::RegexPreProcessor::replace_backreferences | ( | const std::string & | original, |
| const backreference_replacements & | replace | ||
| ) | [static] |
Replace into the original string occurrences of backreferences with the corresponding string in the replace parameter, i.e.,
backreference will be replaced with replace[n-1].
| original | |
| replace |
| const std::string srchilite::RegexPreProcessor::replace_backreferences | ( | const std::string & | original, |
| const regex_match_results & | results | ||
| ) | [static] |
Replace into the original string occurrences of backreferences with the corresponding subexpressions that matched in the results.
Notice that we assume that the results come from a regular expression without nested subexpressions.
| original | |
| results |
| const string srchilite::RegexPreProcessor::replace_references | ( | const std::string & | original, |
| const backreference_replacements & | replace | ||
| ) | [static] |
Replace into the original string occurrences of backreferences with the corresponding string in the replace parameter, i.e., n} backreference will be replaced with replace[n-1].
| original | |
| replace |
| const string srchilite::RegexPreProcessor::replace_references | ( | const std::string & | original, |
| const regex_match_results & | results | ||
| ) | [static] |
Replace into the original string occurrences of backreferences with the corresponding subexpressions that matched in the results.
Notice that we assume that the results come from a regular expression without nested subexpressions.
| original | |
| results |
| const subexpressions_strings * srchilite::RegexPreProcessor::split_marked_subexpressions | ( | const std::string & | s | ) | [static] |
Splits the marked subexpressions of a regular expression made up of only marked subexpressions and no nested subexpressions and char outside subexpressions (thus, before calling this, you must make sure that num_of_marked_subexpressions did not return an error.