Match.start()#
relationalai.std.re
#Match.start() -> Expression
Returns the 0-based starting 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.start(), "match_start"), # Get the start position of the match
)
print(response.results)
# name match_start
# 0 RelationalAI 10