Match.end()#

relationalai.std.re
#Match.end() -> Expression

Returns the 0-based ending position of the match. Must be used in a rule or query context.

Parameters#

None.

Returns#

An Expression object.

Example#

#import relationalai as rai
from relationalai.std import alias, re


# =====
# SETUP
# =====

model = rai.Model("MyModel")
Company = model.Type("Company")

with model.rule():
    Company.add(name="RelationalAI")
    Company.add(name="Snowflake")


# =======
# EXAMPLE
# =======

with model.query() as select:
    company = Company()
    # Filter companies whose name contains 'AI'.
    match = re.search(r"AI", company.name)
    response = select(
        company.name,
        alias(match.end(), "match_end"),  # Get the ending position of the match
    )

print(response.results)
#            name  match_end
# 0  RelationalAI         12

See Also#