What are the advantages and disadvantages of using regular expressions to replace line breaks in PHP compared to other methods?

When replacing line breaks in PHP, regular expressions can be a powerful tool as they allow for more flexibility in identifying different types of line breaks. However, using regular expressions can also be more complex and resource-intensive compared to simpler methods like using the `str_replace()` function. It is important to weigh the advantages of using regular expressions, such as increased flexibility, against the potential disadvantages, such as increased complexity and performance overhead.

// Using regular expressions to replace line breaks in PHP
$text = "Hello\nworld!";
$pattern = "/\r?\n/";
$replacement = "<br>";
$new_text = preg_replace($pattern, $replacement, $text);

echo $new_text;