0
$regex = array(
                "`^([\t\s]+)`ism"=>'',
                "`^\/\*(.+?)\*\/`ism"=>"",
                "`([\n\A;]+)\/\*(.+?)\*\/`ism"=>"$1",
                "`([\n\A;\s]+)//(.+?)[\n\r]`ism"=>"$1\n",
                "`(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+`ism"=>"\n"
            );
$file_content = preg_replace(array_keys($regex), $regex, $file_content);

I received this warning:

preg_replace(): Compilation failed: escape sequence is invalid in character class at offset 4

1 Answer 1

0

The reason is \A inside square brackets.

Here is a good answer about the reason in general.

PHP PCRE engine migrates to PCRE2

PCRE2 is more strict in the pattern validations, so after the upgrade, some of your existing patterns could not compile anymore.

Sign up to request clarification or add additional context in comments.

2 Comments

OK, So what do I need put insted the - "\A" ?
I don't know what was your goal using \A in patterns. Looks like you can just remove it. Or move it outside of square brackets, like this ...(\A|[\n;]+...

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.