Class mata::applications::strings::replace::ReluctantReplace

class ReluctantReplace

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 aut to replacement.

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.

  • alphabetAlphabet over which to create the NFT.

  • replace_mode – Whether to replace all or just the single (the leftmost) occurrence of regex.

  • begin_markerSymbol 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 literal to replacement.

Parameters:
  • literal – Literal to replace.

  • replacement – Literal to replace with.

  • alphabetAlphabet over which to create the NFT.

  • replace_mode – Whether to replace all or just the single (the leftmost) occurrence of literal.

  • end_markerSymbol 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_symbol to replacement.

Parameters:
  • from_symbolSymbol to replace.

  • replacementSymbol to replace with.

  • alphabetAlphabet over which to create the NFT.

  • replace_mode – Whether to replace all or just the single (the leftmost) occurrence of from_symbol.

Returns:

The reluctant leftmost replace NFT.

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_symbol to replacement.

Parameters:
  • from_symbolSymbol to replace.

  • replacement – Literal to replace with.

  • alphabetAlphabet over which to create the NFT.

  • replace_mode – Whether to replace all or just the single (the leftmost) occurrence of from_symbol.

Returns:

The reluctant leftmost replace NFT.