[php] Preg_match backtrack error

When I use the regex (.*)*[0] everything works well:

preg_match('/(.*)*[0]/', 'this is a test string'); var_dump(preg_last_error()); // no code's returned 

But when I add another character to char class, it will throw out error:

preg_match('/(.*)*[01]/', 'this is a test string'); var_dump(preg_last_error()); // int(2) 

Code #2 means PREG_BACKTRACK_LIMIT_ERROR. What an additional character can do here though?

This question is related to php regex preg-match

The answer is



Questions with php tag:

I am receiving warning in Facebook Application using PHP SDK Pass PDO prepared statement to variables Parse error: syntax error, unexpected [ Preg_match backtrack error Removing "http://" from a string How do I hide the PHP explode delimiter from submitted form results? Problems with installation of Google App Engine SDK for php in OS X Laravel 4 with Sentry 2 add user to a group on Registration php & mysql query not echoing in html with tags? How do I show a message in the foreach loop? Target class controller does not exist - Laravel 8 Message: Trying to access array offset on value of type null Array and string offset access syntax with curly braces is deprecated Visual Studio Code PHP Intelephense Keep Showing Not Necessary Error How to fix "set SameSite cookie to none" warning? The POST method is not supported for this route. Supported methods: GET, HEAD. Laravel Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac What does double question mark (??) operator mean in PHP Post request in Laravel - Error - 419 Sorry, your session/ 419 your page has expired PHP with MySQL 8.0+ error: The server requested authentication method unknown to the client php mysqli_connect: authentication method unknown to the client [caching_sha2_password] Converting a POSTMAN request to Curl Composer require runs out of memory. PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required Issue in installing php7.2-mcrypt Xampp localhost/dashboard How can I run specific migration in laravel How to change PHP version used by composer Laravel 5 show ErrorException file_put_contents failed to open stream: No such file or directory Artisan migrate could not find driver phpMyAdmin ERROR: mysqli_real_connect(): (HY000/1045): Access denied for user 'pma'@'localhost' (using password: NO) Ajax LARAVEL 419 POST error Laravel 5.5 ajax call 419 (unknown status) laravel 5.5 The page has expired due to inactivity. Please refresh and try again "The page has expired due to inactivity" - Laravel 5.5 How to increment a letter N times per iteration and store in an array? Can't install laravel installer via composer Only on Firefox "Loading failed for the <script> with source" Is there way to use two PHP versions in XAMPP? How to prevent page from reloading after form submit - JQuery laravel Eloquent ORM delete() method No Application Encryption Key Has Been Specified General error: 1364 Field 'user_id' doesn't have a default value How to logout and redirect to login page using Laravel 5.4? How to uninstall an older PHP version from centOS7 How to Install Font Awesome in Laravel Mix PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers Laravel - htmlspecialchars() expects parameter 1 to be string, object given How to downgrade php from 7.1.1 to 5.6 in xampp 7.1.1?

Questions with regex tag:

Why my regexp for hyphenated words doesn't work? grep's at sign caught as whitespace Preg_match backtrack error regex match any single character (one character only) re.sub erroring with "Expected string or bytes-like object" Only numbers. Input number in React Visual Studio Code Search and Replace with Regular Expressions Strip / trim all strings of a dataframe return string with first match Regex How to capture multiple repeated groups? How do I use a regex in a shell script? How to find and replace with regex in excel VSCode regex find & replace submatch math? How can I remove the last character of a string in python? Regex Explanation ^.*$ Best way to verify string is empty or null Check for special characters in string Matching strings with wildcard MSSQL Regular expression Phone Number Validation MVC Swift extract regex matches How do I deal with special characters like \^$.?*|+()[{ in my regex? How would I get everything before a : in a string Python Select columns based on string match - dplyr::select How to validate email id in angularJs using ng-pattern Check if string contains only letters in javascript Reference - What does this regex mean? Apache 2.4 - Request exceeded the limit of 10 internal redirects due to probable configuration error Count the number of Occurrences of a Word in a String How to use Regular Expressions (Regex) in Microsoft Excel both in-cell and loops Python, remove all non-alphabet chars from string Regex for Mobile Number Validation Regex date validation for yyyy-mm-dd regex match any whitespace Design DFA accepting binary strings divisible by a number 'n' Jquery Value match Regex Splitting string with pipe character ("|") How to use regex in XPath "contains" function How to replace all special character into a string using C# Regex pattern inside SQL Replace function? Check if a string matches a regex in Bash script Regular expression to search multiple strings (Textpad) How do I remove all non-ASCII characters with regex and Notepad++? Replace all non Alpha Numeric characters, New Lines, and multiple White Space with one Space Regex replace uppercase with lowercase letters Regex remove all special characters except numbers? Concrete Javascript Regex for Accented Characters (Diacritics) Java: Replace all ' in a string with \' Email address validation in C# MVC 4 application: with or without using Regex bash, extract string before a colon

Questions with preg-match tag:

Preg_match backtrack error Regular expression containing one word or another How to search in an array with preg_match? PHP preg_match - only allow alphanumeric strings and - _ characters Delimiter must not be alphanumeric or backslash and preg_match PHP is_numeric or preg_match 0-9 validation Regex: Specify "space or start of string" and "space or end of string" PHP regular expressions: No ending delimiter '^' found in PHP - regex to allow letters and numbers only