get_users meta_query: REGEXP not working for matching new lines
I found the problem and also fixed a bug in the regex. Final code: ‘meta_query’ => array( array( ‘key’ => ‘my_meta_field’, ‘value’ => “(^|\n|\r\n)99999($|\n|\r\n)”, ‘compare’ => ‘REGEXP’, ), ), The problem here was WordPress was adding extra backslashes on the special characters. By wrapping the expression in double quotes, this problem was solved. Also added … Read more