+
Point of view
All features
deferred class REGULAR_EXPRESSION
Summary
Regular expression matching and substitution capabilities. Use REGULAR_EXPRESSION_BUILDER to create REGULAR_EXPRESSION objects.
See tutorial/regular_expression for usage.
Direct parents
Insert list: ANY
Known children
Inherit list: BACKTRACKING_REGULAR_EXPRESSION
Class invariant
Overview
Features
matching capabilities
{ANY}
substitution capabilities
{ANY}
Error informations
{ANY}
{}
{}
match (text: ABSTRACT_STRING): BOOLEAN
effective function
{ANY}
Returns True if Current regular_expression can match the text.
require ensure
match_from (text: ABSTRACT_STRING, first_index: INTEGER_32): BOOLEAN
deferred function
{ANY}
Returns True if Current regular_expression can match the text starting from first_index.
require ensure
match_next (text: ABSTRACT_STRING): BOOLEAN
effective function
{ANY}
Returns True if Current regular_expression can match the same text one more time.
Must be called after a successful match or math_from or match_next using the same text.
See also match, match_from, last_match_succeeded.
require ensure
last_match_succeeded: BOOLEAN
effective function
{ANY}
Did last match succeed?
See also match, match_from.
last_match_first_index: INTEGER_32
effective function
{ANY}
The starting position in the text where starts the sub-string who is matching the whole pattern.
See also match, match_from.
require ensure
  • Result > 0
last_match_last_index: INTEGER_32
effective function
{ANY}
The last position in the text where starts the sub-string who is matching the whole pattern.
See also match, match_from.
require ensure
last_match_count: INTEGER_32
effective function
{ANY}
Length of the string matching the whole pattern.
group_count: INTEGER_32
effective function
{ANY}
Number of groups in Current regular expression.
group_names: TRAVERSABLE[FIXED_STRING]
effective function
{ANY}
The names of the matched named group.
ensure
has_group_name (name: ABSTRACT_STRING): BOOLEAN
effective function
{ANY}
Is there a group names name?
require
  • name /= Void
ith_group_matched (i: INTEGER_32): BOOLEAN
effective function
{ANY}
Did the ith group match during last match?
named_group_matched (name: ABSTRACT_STRING): BOOLEAN
effective function
{ANY}
Did the group named name match during the last match?
require
ith_group_first_index (i: INTEGER_32): INTEGER_32
effective function
{ANY}
First index in the last matching text of the ith group.
See also group_count.
require ensure
named_group_first_index (name: ABSTRACT_STRING): INTEGER_32
effective function
{ANY}
First index in the last matching text of the group named name.
See also group_names.
require
ith_group_last_index (i: INTEGER_32): INTEGER_32
effective function
{ANY}
Last index in the last matching text of the ith group.
require ensure
named_group_last_index (name: ABSTRACT_STRING): INTEGER_32
effective function
{ANY}
Last index in the last matching text of the group named name.
ith_group_count (i: INTEGER_32): INTEGER_32
effective function
{ANY}
Length of the ith group of Current in the last matching.
named_group_count (name: ABSTRACT_STRING): INTEGER_32
effective function
{ANY}
Length of the group named name in the last matching.
require ensure
for_all_matched_named_groups (text: ABSTRACT_STRING, action: PROCEDURE[TUPLE 2[FIXED_STRING, STRING]])
effective procedure
{ANY}
Call the action for each group that matched during the last match.
The first action argument is the name of the group; the second is its content. The order of the action calls is the ascending order of the group definitions in the pattern.
Note: the same STRING objects may be reused, so be sure to copy them if you want to keep them.
require
append_heading_text (text: ABSTRACT_STRING, buffer: STRING)
effective procedure
{ANY}
Append in buffer the text before the matching area.
text is the same as used in last matching.
See also append_pattern_text, append_tailing_text, append_ith_group.
require ensure
append_pattern_text (text: ABSTRACT_STRING, buffer: STRING)
effective procedure
{ANY}
Append in buffer the text matching the pattern.
text is the same as used in last matching.
See also append_heading_text, append_tailing_text, append_ith_group.
require ensure
append_tailing_text (text: ABSTRACT_STRING, buffer: STRING)
effective procedure
{ANY}
Append in buffer the text after the matching area.
text is the same as used in last matching.
See also append_heading_text, append_pattern_text, append_ith_group.
require ensure
append_ith_group (text: ABSTRACT_STRING, buffer: STRING, i: INTEGER_32)
effective procedure
{ANY}
Append in buffer the text of the ith group.
text is the same as used in last matching.
See also append_pattern_text, group_count.
require ensure
append_named_group (text: ABSTRACT_STRING, buffer: STRING, name: ABSTRACT_STRING)
effective procedure
{ANY}
Append in buffer the text of the group named name.
text is the same as used in last matching.
See also append_pattern_text, group_name.
require ensure
named_group_value (text: ABSTRACT_STRING, name: ABSTRACT_STRING): STRING
effective function
{ANY}
Returns the text of the group named name (always the same STRING!)
text is the same as used in last matching.
See also append_named_group, group_name.
require
prepare_substitution (p: ABSTRACT_STRING)
effective procedure
{ANY}
Set pattern p for substitution.
If pattern p is not compatible with the Current regular expression, the pattern_error_message is updated as well as pattern_error_position.
See also substitute_in, substitute_for, substitute_all_in, substitute_all_for.
require
  • p /= Void
ensure
last_substitution: STRING
effective function
{ANY}
You need to copy this STRING if you want to keep it.
substitute_for (text: ABSTRACT_STRING)
effective procedure
{ANY}
This call has to be preceded by a successful matching on the same text.
Then the substitution is made on the matching part. The result is in last_substitution.
See also prepare_substitution, last_substitution, substitute_in.
require ensure
substitute_in (text: STRING)
effective procedure
{ANY}
This call has to be preceded by a successful matching on the same text.
Then the substitution is made in text on the matching part (text is modified).
See also prepare_substitution, substitute_for.
require ensure
substitute_all_for (text: ABSTRACT_STRING)
effective procedure
{ANY}
Every matching part is substituted.
No preliminary matching is required. The result is in last_substitution.
See also prepare_substitution, last_substitution, substitute_all_in.
require ensure
substitute_all_in (text: STRING)
effective procedure
{ANY}
Every matching part is substituted.
No preliminary matching is required. text is modified according to the substitutions is any.
See also prepare_substitution, last_substitution, substitute_all_for.
require ensure
can_substitute: BOOLEAN
effective function
{ANY}
Substitution is only allowed when some valid substitution pattern has been registered and after a successful pattern matching.
substitution_pattern_ready: BOOLEAN
writable attribute
{ANY}
True if some valid substitution pattern has been registered.
pattern_error_message: STRING
writable attribute
{ANY}
Error message for the substitution pattern.
pattern_error_position: INTEGER_32
writable attribute
{ANY}
Error position in the substitution pattern.
save_matching_text (text: ABSTRACT_STRING): BOOLEAN
effective function
{}
Used in assertion only.
Side-effect: save the text
ensure
  • Result
    Assertion only feature

invalidate_last_match
effective procedure
{}
Used to prevent 2 substitutions without intermediate matching.
valid_substrings (text: ABSTRACT_STRING): BOOLEAN
effective function
{}
Used in assertion only.
require ensure
  • Result
    Method for assertion only (error position is element item i)

valid_substitution: BOOLEAN
effective function
{}
Used in assertion only.
ensure
  • Result
    Method for assertion only

substitute_all_without_tail (text: ABSTRACT_STRING): INTEGER_32
effective function
{}
Substitute all matching parts from text.
The resulting text in last_substitution, except the end. The part of text from Result up to the end is not copied.
require ensure
substrings_first_indexes: ARRAY[INTEGER_32]
writable attribute
{}
Item(0) is the starting position in the text where starts the substring who is matching the whole pattern.
Next elements are the starting positions in the text of substrings matching sub-elements of the pattern.
Elements before item(0) refers to positions in the substitution_pattern. They are stored in reverse order, the first verbatim string being at index -1, the second one at index -2...
substrings_last_indexes: ARRAY[INTEGER_32]
writable attribute
{}
The ending position of the string starting at position found in matching_position at the same index.
writable attribute
{}
The names of the groups, if those names exist
group_names_memory: COLLECTION[FIXED_STRING]
writable attribute
{}
Cache for group_names
substitution_pattern: STRING
once function
{}
compiled_substitution_pattern: FAST_ARRAY[INTEGER_32]
writable attribute
{}
This array describe the substitution text as a suite of strings from substrings_first_indexes.
last_match_text: STRING
effective function
{}
For assertion only.
set_group_names_memory
effective procedure
{}
last_match_text_memory: STRING
writable attribute
{}
For assertion only.
last_substitution_memory: STRING
writable attribute
{}
_inline_agent38 (s: FIXED_STRING): BOOLEAN
frozen
effective function
{}
_inline_agent39 (s: FIXED_STRING): BOOLEAN
frozen
effective function
{}
_inline_agent40 (s: FIXED_STRING): BOOLEAN
frozen
effective function
{}
_inline_agent41 (i: INTEGER_32, s: FIXED_STRING): BOOLEAN
frozen
effective function
{}