What are common challenges when using regular expressions in PHP for extracting currency symbols from a string?
Common challenges when using regular expressions in PHP for extracting currency symbols from a string include ensuring that the regex pattern matches all possible variations of currency symbols, handling cases where the currency symbol is followed by a space or other characters, and accounting for different encoding formats that may affect the matching process.
// Example code snippet to extract currency symbols from a string using regular expressions
$string = "The total amount is $100.50";
$pattern = '/[£€$¥]/'; // Regex pattern to match common currency symbols
preg_match($pattern, $string, $matches);
$currency_symbol = $matches[0];
echo "Currency symbol found: " . $currency_symbol;