What are some resources or tutorials for effectively using regular expressions in PHP to manipulate text containing links?

When working with text containing links in PHP, regular expressions can be a powerful tool for manipulating and extracting specific information from the text. By using regular expressions, you can easily identify and modify links within the text to suit your needs. One way to effectively use regular expressions in PHP to manipulate text containing links is to use the preg_replace() function. This function allows you to search for a specific pattern in the text and replace it with another value. In this case, you can use a regular expression pattern to match URLs and then manipulate them as needed. Here is an example PHP code snippet that demonstrates how to use regular expressions to manipulate text containing links:

```php
<?php
$text = "Check out my website at https://www.example.com. For more information, visit http://www.example.org.";

// Define a regular expression pattern to match URLs
$pattern = '/(https?|ftp):\/\/[^\s\/$.?#].[^\s]*/';

// Replace URLs in the text with a custom link
$new_text = preg_replace($pattern, '<a href="$0">$0</a>', $text);

echo $new_text;
?>
```

In this code snippet, we first define a regular expression pattern to match URLs using the `$pattern` variable. We then use the `preg_replace()` function to replace each matched URL in the text with a custom link that wraps the URL in an anchor tag. Finally, we output the modified text containing the links.