Find content within brackets or parentheses
This is how to extract a sub string within a string by brackets or parentheses.
<?php
//within brackets
preg_match('/\[(.*?)\]/', "vRanger Notification [Daily Backup]: 3 (successful), 1 failed, 0 aborted, 0 canceled", $out);
// result: Array ( [0] =--> [Daily Backup] [1] => Daily Backup)
//within parentheses
preg_match('/\((.*?)\)/', "vRanger Notification [Daily Backup]: 3 (successful), 1 failed, 0 aborted, 0 canceled", $out);
// result: Array ( [0] => (successful) [1] => successful)
?>
Knowledge keywords: