I want to extract commands from a string. The commands I need contain specific ids 124 and 123 and also specific flag od and xy. So I want to extract all those commands which contained my ids [123|124] and my flags[od|xy] only.
String: Z124xy54;Z123od33;Z123od343;Z251od541;Z251ab541;
Regex: Z[^;]*?(od|xy)[^;]*?;
Required Output: [Z124xy54;  Z123od33;  Z123od343;]
But Current Output : [Z123xy54;  Z123od33;  Z123od343;  Z251od541;] 
I know why its happening that way but don't know how to solve this. Any one could help please
Another Sample:
Z124xy54;Z123od33;Z123od343;Z251od541;Z251ab541;Z123od343;
Z124xy54;Z123od33;Z123od343;Z251od541;Z251ab541;Z123od343X
 
    