@mac
To match all occurrences of @__('...') in a string using PHP regex, you can use the preg_match_all function. Here is an example code:
1 2 3 4 5 6 |
$string = "This is a sample string with @__('example1') and @__('example2')";
preg_match_all('/@__('(.*?)')/', $string, $matches);
// The matches array will contain all the matches
print_r($matches[0]);
|
In the above code, the regex pattern is /@__('(.*?)')/:
The captured matches are stored in the $matches array, where $matches[0] contains all the exact matches found in the string.
Running the above code will output:
1 2 3 4 5 |
Array
(
[0] => @__('example1')
[1] => @__('example2')
)
|
Now, you can access individual matches or iterate over the array to perform further actions with each match.