How can regular expressions be used to search for a character sequence in PHP?

Regular expressions can be used in PHP to search for a specific character sequence within a string. This can be achieved using the preg_match() function, which takes a regular expression pattern and a string to search within. If the pattern is found in the string, preg_match() returns 1, otherwise it returns 0. By using regular expressions, you can search for complex patterns or sequences of characters with ease.

$string = "Hello, this is a test string";
$pattern = "/test/";

if (preg_match($pattern, $string)) {
    echo "Pattern found in the string.";
} else {
    echo "Pattern not found in the string.";
}