Quote:
In the end I decided upon a simpler solution that also works as expected.
|
Actually it didn’t work as I wanted. Using the example of John George etc. there were matches for not only John but also Johnson, Johnjo LongJohn and so on.
To counteract this I tried wrapping John in \b anchors in the function - no matches at all. After researching online I tried escaping the backslash \\b - no matches. After more reading I tried escaping the escape characters \\\\b - no matches. After even more research I tried the raw data solution r”\bJohn” - no matches.
I would like to go back to the dict method again (as described in lomkiri’s suggestion above). However I think I will probably have the same issue there when the pairs are passed to the function from the json file.
Is there another way around this?