I have a requirement where I need to match text like “testuser” or “joeperson” to data like “test.user” or “joe.person”. I won’t know where the period is in the incoming search term in the actual data. In short, we’ve got URLs like /cart/[user name which can have a period]/items/ and I need to search for all usernames that match that pattern.
I’m using Django and Python against a MySQL database. I know that I can do a Django query like:
User.objects.filter(username__regex='[some crazy pattern]’) but it’s the crazy pattern I need help with.
Thanks so much!
Use an SQL query like the following:
Or in Django: