It will work, but you need to make the REGEXP more strict as your current REGEXP will do partial matches. The below will strictly match the IDs you've supplied.
Code:
/^(23|24|21|22|19|20|17|18|15|16|13|14|11|12|6|10|8|7|4|5|2|3|1)$/
You don't need to use a REGEXP operator though. You can use an "Is In" or "Is Not In" operator then set the Delimiter field to a comma. You can then just supply a comma separated list of IDs without needing to worry about the REGEXP.