REGEX operator only matches characters at the beginning of a string

Open
#207 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
1-3 hours
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
backend

Research direction

Open flag_engine/segments/evaluator.py at the linked REGEX implementation and read Python’s Pattern.match and Pattern.search documentation. Reproduce the reported hello-world/world case and verify that the REGEX operator matches the substring as requested while preserving expected beginning-of-string behavior.

Written by the indexing model from the issue text.

Description

REGEX is implemented using Pattern.match, which only checks the beginning of the search string:

If zero or more characters at the beginning of string match this regular expression, return a corresponding Match

This means a regular expression like world will not match a trait value of hello-world.

We should be using Pattern.search instead: https://docs.python.org/3.11/library/re.html#re.Pattern.search

Dominant language
Python
Stars
10
Forks
5
Avg merge
4d 8m
Merged PRs (30d)
3

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Flagsmith/flagsmith-engine

All issues in Flagsmith/flagsmith-engine

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.