Menu

#294 Recognize ( and | as regex metacharacters in extended RE

None
closed-accepted
None
5
2018-03-19
2018-03-13
No

This could be a bug or a feature request. (See also Stack Overflow question https://stackoverflow.com/questions/49231149/).

The code in find.c that recognizes regular expressions does not recognize that ( and | are metacharacters in regular expressions, so searching for 'foo|bar' (or for 'err_(remark|error)' does not trigger a regular expression search. The fix is trivial — add ( and | to the list of regular expression metacharacters.

--- find.c.original 2014-11-20 13:12:54.000000000 -0800
+++ find.c 2018-03-12 20:47:05.000000000 -0700
@@ -710,7 +710,7 @@
return(NOERROR);
}
/ see if the pattern is a regular expression /

  • if (strpbrk(pattern, "^.[{*+$") != NULL) {
  • if (strpbrk(pattern, "^.[{+$|(") != NULL) {
    isregexp = YES;
    } else {
    /
    check for a valid C symbol */

I have provided the patch as a file — see the attachment (I hope).

1 Attachments

Discussion

  • Jonathan Leffler

    Sorry; the patch text in the bug report got mangled by MarkDown taking the * in the comment markers as indicating italics, etc. The patch, I trust, is clean. (There are also minor grammatical errors in the report, such as unbalanced parenthese — sorry about that, too.)

     
  • Neil Horman

    Neil Horman - 2018-03-13
    • status: open --> open-accepted
    • assigned_to: Neil Horman
    • Group: -->
     
  • Neil Horman

    Neil Horman - 2018-03-13

    Hans, I have no issue with this patch, do you object?

     
  • Neil Horman

    Neil Horman - 2018-03-19
    • status: open-accepted --> closed-accepted
     

Log in to post a comment.

MongoDB Logo MongoDB