preprocess a regular expression, e.g., transform "()" into "(?:)"
More...
#include <regexpreprocessor.h>
Static Public Member Functions
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].
More...
Replace into the original string occurrences of backreferences with the corresponding subexpressions that matched in the results.
More...
static const std::string
preprocess (const std::string &s)
translates marked subexpressions (...) into non marked subexpressions (?: )
More...
translates the expression into a case nonsensitive expression, i.e., foo is translated into [Ff][Oo][Oo]
More...
counts the number of marked subexpressions (...)
More...
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).
More...
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.
More...
Checks whether the passed regular expression string contains a backreference (e.g., either 1円 or a conditional with a backreference (?(1)...)
More...
counts the number of backreferences (also in conditionals)
More...
counts the number of references (i.e., reference to a matched subexpression of another regular expression)
More...
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].
More...
Replace into the original string occurrences of backreferences with the corresponding subexpressions that matched in the results.
More...
Detailed Description
preprocess a regular expression, e.g., transform "()" into "(?:)"
Member Function Documentation
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)...)
- Returns
- true if the passed regular expression string contains a backreference
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]
- Returns
- the translated string
backreference_info srchilite::RegexPreProcessor::num_of_backreferences
(
const std::string &
s )
static
counts the number of backreferences (also in conditionals)
- Parameters
-
s
- Returns
- the number of backreferences and the highest backreference number
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.
- Parameters
-
s
allow_outer_char whether we allow characters outside marked subexps
allow_outer_nonmarked whether we allow outer nonmarked subexps
- Returns
- the struct containing the number of marked subexpressions and possible errors
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)
- Parameters
-
s
- Returns
- the number of backreferences and the highest backreference number
unsigned int srchilite::RegexPreProcessor::num_of_subexpressions
(
const std::string &
s )
static
counts the number of marked subexpressions (...)
- Parameters
-
s
- Returns
- the number of marked subexpressions
const string srchilite::RegexPreProcessor::preprocess
(
const std::string &
s )
static
translates marked subexpressions (...) into non marked subexpressions (?: )
- Returns
- the translated string
const std::string srchilite::RegexPreProcessor::replace_backreferences
(
const std::string &
original,
)
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].
- Warning
- For the moment this is never used but in testing
- Parameters
-
original
replace
- Returns
- the result of the replacement
const std::string srchilite::RegexPreProcessor::replace_backreferences
(
const std::string &
original,
)
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.
- Warning
- For the moment this is never used but in testing
- Parameters
-
original
results
- Returns
- the result of the replacement
const string srchilite::RegexPreProcessor::replace_references
(
const std::string &
original,
)
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].
- Parameters
-
original
replace
- Returns
- the result of the replacement
const string srchilite::RegexPreProcessor::replace_references
(
const std::string &
original,
)
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.
- Parameters
-
original
results
- Returns
- the result of the replacement
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.
- Returns
- the subexpressions in a collection (this is allocated on the heap, so it is up to the caller to delete it)
The documentation for this class was generated from the following files:
- /home/bettini/work/source-highlight/src-highlite/lib/srchilite/regexpreprocessor.h
- /home/bettini/work/source-highlight/src-highlite/lib/srchilite/regexpreprocessor.cpp