admin管理员组

文章数量:1415655

I am trying to get a meta query with a regular expression to work.

I have a custom post type with a custom field "participant-id".

The custom field stores a comma-delimited string of user IDs, like: 56,123,99,199

My query is:

'meta_query' => array(
               array(
                   'key' => 'event-id',
                   'value' => $eventID,
                   'compare' => '=',
               ),
                array(
                   'key' => 'participant-id',
                   'value' => "(?<!(\d|\w))99(?!(\d|\w))",
                   'compare' => "REGEXP",
               )
            )

According to the WP Codex and all other examples I have found here on the topic, this should work, but it doesn't. The right values are not returned, meaning that in this case, the post that has a custom field with a participant id of 99 in it is not found.

I am trying to get this regular expression to work because before I had a LIKE compare operator and it would consider 99 and 199 to be the same, giving false results.

Any suggestions?

Thanks.

本文标签: Meta query with regular expression does not work