I need help please. I would like to extract all dates from the string below. Any help using regex or any other function? I tried using the PHP code below but I'm getting an error: Warning: preg_match(): Compilation failed: missing closing parenthesis at offset 13.
<?php
$matches = [];
if (preg_match('/b>|-(.*?)-| (/', $dates["scheduled"], $matches) == 1) {
var_dump($matches);
}
?>
Thanks.
<br>5449431| <b style='color:orange;'>SCHEDULED </b>|04/02/2021| ($56.49)<br>
<br>5449616| <b style='color:orange;'>SCHEDULED </b>|04/09/2021| ($51.49)<br>
<br>_______| <b style='color:orange;'>SCHEDULED </b>|04/16/2021| ($51.49)<br>
You need to escape the regex meta characters |
and (
and remove those -
characters, like this:
<?php
$matches = [];
if (preg_match('/b>\|(.*?)\| \(', $dates["scheduled"], $matches) == 1){
var_dump($matches);
}
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.