---
title: "Regex is not working"
canonical: "https://support.appfire.com/space/YACC/152928460/Regex%20is%20not%20working"
format: markdown
---
> Macro (aura-html)

This can happen when assuming different default behavior than YACC provides. Refer to [Oracle's documentation](https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html) for details on Java Regex engine defaults and [available options](https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html#field.detail). 

Here are some of the most common cases when the expected regex behavior does not match YACC defaults.

## The `.` character in regex is not matching newlines

If you use a regular expression to match multiple lines of a commit message, it may not behave as expected because by default, in Java regular expressions, the `.` character doesn’t match newlines.

You can work around this in two ways:

- Explicitly include the newline character in your regular expression, e.g. `(.|\n)*`
- Add `(?s)` to the beginning of your regular expression. This enables [Pattern.DOTALL](https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html#DOTALL), meaning that the `.` character also matches newlines.

## The `^` and `$` are not matching every line in a multi-line input

By default, these expressions only match at the beginning and the end of the entire input sequence. To enable [Pattern.MULTILINE](https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html#MULTILINE) matching mode, add `(?m)` prefix to your regex. In multiline mode, the expressions `^` and `$` match just after or before, respectively, a line terminator or the end of the input sequence.

## Case-sensitive matching is performed.

By default, YACC distinguishes letter cases. Add `(?i)` prefix to your regex to perform case-insensitive matching.

## The commit message contains unexpected text

Bitbucket automatically inserts commit summaries in pull request merges, which can complicate commit message regex checks.

### Workaround options

1. Disable checking merge commits by enabling the **Exclude Merge Commits** option from the YACC **Exclusions** tab.
2. Turn off commit summaries in pull request commits (Bitbucket 6.7+) as [described here](https://confluence.atlassian.com/bitbucketserver/pull-request-merge-strategies-844499235.html).
3. Update your regex to allow the commit summaries on pull request merge commits.