Relevance for matching string

Let’s say there is some relevance code that’s looking for string “abc123” in something, maybe the registry on a Windows computer.

The Windows computer has a key that has data “abc123 def456 ghi789”. We could match that with a “contains” clause in the relevance code.

But how do we prevent the “contains” clause from also matching a key that has “abc123-x def456-y ghi789-z” ?

You have to determine what your “word” delimiter is if you want do to something like matching a whole word.

One method would be to split on spaces, and then require an exact match on the given word

Q: substrings separated by " " whose (it="abc123") of "abc123 def456 ghi789"
A: abc123

Depending on the use-case, complexity of match, and data size, you might also use Regular Expressions, which can match as simple or as complex as you like…

Q: matches(regex("abc123")) of "abc123 def456 ghi789"
A: abc123

Q: matches(regex("abc\d+")) of "abc123 def456 ghi789"
A: abc123

Q: matches(regex("abc[^\s]+")) of "abc123 def456 ghi789"
A: abc123

Q: parenthesized parts 2 of matches(regex("(^|\s)(abc[^\s]+)")) of "abc123 def456 ghi789"
A: abc123

One more thing to throw into the mix - the registry string could also just be “abc123”.

How could I work that into this?

Still works:

Q: substrings separated by " " whose (it="abc123") of "abc123"
A: abc123
1 Like