Redis scan match only support glob style matching. It cannot do regex matching. In order to achieve your goal, you have two options:
- Scan all keys and do matching on client side.
- Use Lua script to do the scan and matching. You can try the following one-liner as an example:
redis-cli eval 'local res = redis.call("scan", ARGV[1]); local matches = {}; for i,v in ipairs(res[2]) do if v == string.match(v, ARGV[2]) then matches[#matches+1] = v end end res[2] = matches; return res' 0 cursor-starting-from-0 'Person:[^:]*'
This one-liner returns results exactly like the built-in scan command. I'm not a Lua expert, and the code is not fully tested.
Also, Lua's matching is NOT regex matching, although it can solve most problems. You need to take Lua's reference to check if it matches your case.