Namespace mata::applications::strings::replace¶
-
namespace replace
Enums
-
enum class ReplaceMode
How many occurrences of the regex to replace, in order from left to right?
Values:
-
enumerator Single
Replace only the first occurrence of the regex.
-
enumerator All
Replace all occurrences of the regex.
-
enumerator Single
Functions
-
Nfa reluctant_nfa(Nfa nfa)
Modify
nfain-place to remove outgoing transitions from final states.If
nfaaccepts empty string, returned NFA will accept only the empty string.- Parameters:
nfa – NFA to modify.
- Returns:
The reluctant version of
nfa.
-
Nft create_identity(Alphabet const *const alphabet, size_t num_of_levels = 2)
Create identity transducer over the
alphabetwithnum_of_levelslevels.
-
Nft create_identity_with_single_symbol_replace(Alphabet const *const alphabet, Symbol from_symbol, Symbol replacement, ReplaceMode replace_mode = ReplaceMode::All)
Create identity input/output transducer with 2 levels over the
alphabetwithlevel_cntlevels with single symbolfrom_symbolreplaced with @to_symbol.
-
Nft create_identity_with_single_symbol_replace(Alphabet const *const alphabet, Symbol from_symbol, const Word &replacement, ReplaceMode replace_mode = ReplaceMode::All)
Create identity input/output transducer with 2 levels over the
alphabetwithlevel_cntlevels with single symbolfrom_symbolreplaced with wordreplacement.
-
Nft replace_reluctant_regex(const std::string ®ex, const Word &replacement, Alphabet const *const alphabet, ReplaceMode replace_mode = ReplaceMode::All, Symbol begin_marker = BEGIN_MARKER)
Create NFT modelling a reluctant leftmost replace of regex
regextoreplacement.The most general replace operation, handling any regex as the part to be replaced.
- Parameters:
regex – A string containing regex to be replaced.
replacement – Literal to be replaced with.
alphabet – Alphabet over which to create the NFT.
replace_mode – Whether to replace all or just the single (the leftmost) occurrence of
regex.begin_marker – Symbol to be used internally as a begin marker of replaced
regex.
- Returns:
The reluctant leftmost replace NFT.
-
Nft replace_reluctant_regex(nfa::Nfa aut, const Word &replacement, Alphabet const *const alphabet, ReplaceMode replace_mode = ReplaceMode::All, Symbol begin_marker = BEGIN_MARKER)
Create NFT modelling a reluctant leftmost replace of regex represented by deterministic automaton
auttoreplacement.The most general replace operation, handling any regex as the part to be replaced.
- Parameters:
aut – deterministic automaton representing regex to be replaced.
replacement – Literal to replace with.
alphabet – Alphabet over which to create the NFT.
replace_mode – Whether to replace all or just the single (the leftmost) occurrence of
regex.begin_marker – Symbol to be used internally as a begin marker of replaced
regex.
- Returns:
The reluctant leftmost replace NFT.
-
Nft replace_reluctant_literal(const Word &literal, const Word &replacement, Alphabet const *const alphabet, ReplaceMode replace_mode = ReplaceMode::All, Symbol end_marker = END_MARKER)
Create NFT modelling a reluctant leftmost replace of literal
literaltoreplacement.- Parameters:
literal – Literal to replace.
replacement – Literal to replace with.
alphabet – Alphabet over which to create the NFT.
replace_mode – Whether to replace all or just the single (the leftmost) occurrence of
literal.end_marker – Symbol to be used internally as an end marker marking the end of the replaced literal.
- Returns:
The reluctant leftmost replace NFT.
-
Nft replace_reluctant_single_symbol(Symbol from_symbol, Symbol replacement, Alphabet const *const alphabet, ReplaceMode replace_mode = ReplaceMode::All)
Create NFT modelling a reluctant leftmost replace of symbol
from_symboltoreplacement.
-
Nft replace_reluctant_single_symbol(Symbol from_symbol, const Word &replacement, Alphabet const *const alphabet, ReplaceMode replace_mode = ReplaceMode::All)
Create NFT modelling a reluctant leftmost replace of symbol
from_symboltoreplacement.
Variables
-
class ReluctantReplace
- #include <strings.hh>
Implementation of all reluctant replace versions.
Public Static Functions
-
static Nft replace_regex(nfa::Nfa aut, const Word &replacement, Alphabet const *const alphabet, ReplaceMode replace_mode = ReplaceMode::All, Symbol begin_marker = BEGIN_MARKER)
Create NFT modelling a reluctant leftmost replace of regex represented by deterministic automaton
auttoreplacement.The most general replace operation, handling any regex as the part to be replaced.
- Parameters:
aut – Deterministic automaton representing regex to be replaced.
replacement – Literal to replace with.
alphabet – Alphabet over which to create the NFT.
replace_mode – Whether to replace all or just the single (the leftmost) occurrence of
regex.begin_marker – Symbol to be used internally as a begin marker of replaced
regex.
- Returns:
The reluctant leftmost replace NFT.
-
static Nft replace_literal(const Word &literal, const Word &replacement, Alphabet const *const alphabet, ReplaceMode replace_mode = ReplaceMode::All, Symbol end_marker = END_MARKER)
Create NFT modelling a reluctant leftmost replace of literal
literaltoreplacement.- Parameters:
literal – Literal to replace.
replacement – Literal to replace with.
alphabet – Alphabet over which to create the NFT.
replace_mode – Whether to replace all or just the single (the leftmost) occurrence of
literal.end_marker – Symbol to be used internally as an end marker marking the end of the replaced literal.
- Returns:
The reluctant leftmost replace NFT.
-
static Nft replace_symbol(Symbol from_symbol, Symbol replacement, Alphabet const *const alphabet, ReplaceMode replace_mode = ReplaceMode::All)
Create NFT modelling a reluctant leftmost replace of symbol
from_symboltoreplacement.
-
static Nft replace_symbol(Symbol from_symbol, const Word &replacement, Alphabet const *const alphabet, ReplaceMode replace_mode = ReplaceMode::All)
Create NFT modelling a reluctant leftmost replace of symbol
from_symboltoreplacement.
-
static Nft replace_regex(nfa::Nfa aut, const Word &replacement, Alphabet const *const alphabet, ReplaceMode replace_mode = ReplaceMode::All, Symbol begin_marker = BEGIN_MARKER)
-
enum class ReplaceMode