How can one address the issue of "Unknown modifier" errors when switching from ereg to preg_match in PHP?

When switching from ereg to preg_match in PHP, the "Unknown modifier" error occurs because preg_match requires delimiters around the regular expression pattern. To solve this issue, simply add delimiters (such as "/") around the pattern to avoid the error.

// Before
if (ereg("^[0-9]+$", $string)) {
    echo "Match found!";
}

// After
if (preg_match("/^[0-9]+$/", $string)) {
    echo "Match found!";
}