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

Regexp Look-ahead is working without a fixed-length regexp

    XMLWordPrintable

Details

    Description

      In the PCRE page, it is written:

      Note that look-ahead and look-behind assertions can only be of fixed length; you cannot have repetition operators or alternations with different lengths

      It is true that for a look-behind, the pattern should have a fixed-length. However, for a look-ahead, this is not requested.

      More information from PERL documentation.

      Example:

      WITH log(X) AS (
      	VALUES
      	-- 'over' does not match because 'cute' does not end with a digit
      	('Do you know the droid? It is over-cute <3'),
      	('I think it is BB-8.'),
      	-- 'BB' does not match because it is preceded by 'not'.
      	('No it is not BB-8. It is R2-D2.')
      )
      -- Search a word preceding by 'is ' and followed by '-\\w*\\d'
      SELECT REGEXP_SUBSTR(X, 'is \\K\\w+(?=-\\w*\\d)')
      FROM log;
      

      Returns:

      (''),
      ('BB'),
      ('R2')
      

      Attachments

        Activity

          People

            greenman Ian Gilfillan
            proust Christian Proust
            Votes:
            0 Vote for this issue
            Watchers:
            1 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.