Skip to content

RegexMatch

relationalai.semantics.std.re
RegexMatch(
regex: StringValue,
value: StringValue,
pos: IntegerValue = 0,
type=RegexMatchType.MATCH,
)

Represents a regex match result with position and grouping support.

RegexMatch.regex: StringValue

The regex pattern used for matching.

RegexMatch.value: StringValue

The string value being matched.

RegexMatch.pos: IntegerValue

The starting position of the match (0-based).

RegexMatch.match: Variable

A Variable representing the matched string.

RegexMatch.start() -> IntegerValue

Get the starting position of the match.

Returns:

  • IntegerValue - The 0-based starting position of the match.
RegexMatch.end() -> IntegerValue

Get the ending position of the match.

Returns:

RegexMatch.span() -> tuple[IntegerValue, IntegerValue]

Get the start and end positions of the match.

Returns:

RegexMatch.group(index: IntegerValue = 0) -> Variable

Get a capture group by index.

.. note:: This method is not yet implemented.

Parameters:

  • index

    (IntegerValue, default: 0) - The index of the capture group (0 for the entire match). Default: 0.

Returns:

  • Variable - A Variable representing the capture group content.
RegexMatch.group_by_name(name: StringValue) -> Variable

Get a named capture group.

.. note:: This method is not yet implemented.

Parameters:

Returns:

  • Variable - A Variable representing the named capture group content.
RegexMatchExpressionVariableDSLBase
 semantics > std > re
├──  fullmatch
├──  match
└──  search
RelationalAI Documentation
└──  Build With RelationalAI
    └──  Understand how PyRel works > Use advanced reasoning > Rules-based reasoning
        └──  Match text with patterns
            └──  Understand how std.re matches work