1.2.599. Invalid Regex

The PCRE regex doesn’t compile. It isn’t a valid regex.

Several reasons may lead to this situation : syntax error, Unknown modifier, missing parenthesis or reference.

Regex are check with the Exakat version of PHP.

Dynamic regex are only checked for simple values. Dynamic values may eventually generate a compilation error.

<?php

// valid regex
preg_match('/[abc]/', $string);

// invalid regex (missing terminating ] for character class
preg_match('/[abc/', $string);

?>

1.2.599.1. Suggestions

  • Fix the regex before running it

1.2.599.2. Specs

Short name

Structures/InvalidRegex

Rulesets

All, Analyze, CE, CI-checks, Changed Behavior

Exakat since

1.0.5

PHP Version

All

Severity

Major

Time To Fix

Quick (30 mins)

Precision

High

Examples

SugarCrm

Available in

Entreprise Edition, Community Edition, Exakat Cloud