3

Let's say I have a rule like this,

- if: '$CI_COMMIT_TITLE =~ /^(fix|feat|perf|docs|build|test|ci|refactor)\S*:/'

It occurs to me that ^ does not match the start of any line in a multiline regex, only the start of the first line. That raises the question,

  • Does anything match the newline?
  • Is there a multi-line regex mode?

Where is the GitLab Regex documented? What Regex implementation do they use?

2 Answers 2

1

Updated answer, according to these docs:

In GitLab 11.9.4, GitLab began internally converting the regexp used in only and except keywords to RE2.

RE2 limits the set of available features due to computational complexity, and some features, like negative lookaheads, became unavailable. Only a subset of features provided by Ruby Regexp are now supported.

From GitLab 11.9.7 to GitLab 14.9, GitLab provided a feature flag to let you use unsafe regexp syntax. We’ve fully migrated to RE2 now, and that feature flag is no longer available.

The same is true for rules and if, like you are using.

TL;DR: GitLab regexps now use Google's RE2 syntax, not Ruby.

1

GitLab uses Ruby's core regex implementation which is Onigmo (Oniguruma-mod). I found that from looking at the source code in Ruby's regex.c.

Official documentation is mostly here: https://github.com/k-takata/Onigmo/blob/master/doc/RE

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.