Open rolodato opened 3 weeks ago
I'm leaning towards closing this issue as a wontfix:
re.search
is significantly less performant..*world
should cater for the described use case, unless I'm missing something.I can confirm using a pattern like .*world.*
works, thanks for that suggestion!
There is probably a better way than using Pattern.search
, it was the first thing that came to mind :)
I would argue this is a bugfix and not a breaking change. We don't document this specifically, but I would say the expectation for "matches regex" is essentially the same way grep
behaves. grep world
does match hello-world-hello
, and does not require adding anything else around world
to match.
We have this assumption built-in to every SDK that I've checked so far.
> 'hello-world-hello'.match(/world/)
[ 'world', index: 6, input: 'hello-world-hello', groups: undefined ]
irb(main):001> 'hello-world-hello'.match?('world')
=> true
package main
import "regexp"
func main() {
matched, err := regexp.Match(`world`, []byte(`hello-world-hello`))
println(matched, err)
// true, nil
}
REGEX
is implemented usingPattern.match
, which only checks the beginning of the search string:This means a regular expression like
world
will not match a trait value ofhello-world
.We should be using
Pattern.search
instead: https://docs.python.org/3.11/library/re.html#re.Pattern.search