Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-12942

REGEXP_INSTR returns 1 when using brackets

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.1.13, 10.2.6
    • 10.1.25, 10.2.7
    • OTHER
    • None
    • ms windows 7 Home Premium 64 bit, Intel i5 750

    Description

      MariaDB Documentation says about REGEXP_INSTR: Returns the position of the first occurrence of the regular expression pattern in the string subject, or 0 if pattern was not found.

      My task is (simplified): finding o followed by a double consonant

      SELECT REGEXP_INSTR('a_kollision', 'o([lm])\\1'); # -> expected 4 got 1
      

      It returns 1 but I would have expected 4 as the position of oll

      Doing the same with replace works:

      # replace works as expected
      SELECT REGEXP_REPLACE('a_kollision', 'o([lm])\\1', '???'); # -> a_k???ision -- OK
      

      It seems that the trouble starts when using brackets in REGEXP_INSTR:

      SELECT REGEXP_REPLACE('a_kollision', 'oll', '???'); # -> a_k???ision  -- OK
      SELECT REGEXP_REPLACE('a_kollision', '(oll)', '???'); # -> a_k???ision  -- OK
      SELECT REGEXP_INSTR('a_kollision', 'oll'); # -> 4  -- OK
      SELECT REGEXP_INSTR('a_kollision', '(oll)'); # -> 1  -- wrong
      

      Checked with latest stable version 10.2.6, default settings.

      Attachments

        Activity

          People

            bar Alexander Barkov
            KoSchmi Konstantin Schmidt
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.