Since you are storing multiple IPs together, you need to parse the data before you send it. The easiest way would be to loop through each comma-delimited list of IPs, and only return IPs that match the original search. Like this pseudocode:


search hash for items matching 1.2.3.*
;found value 2.3.4.5,1.2.3.4,5.6.7.8
loop through each IP in the list
IP 2.3.4.5 doesn't match 1.2.3.*, so don't show
IP 1.2.3.4 does match 1.2.3.*, so show
IP 5.6.7.8 doesn't match 1.2.3.*, so don't show


-genius_at_work