I have the following regex:
(<div class="dotted-highlight">(.*?)\s*){2,}<ul>
which is matching the following string:
<div class="dotted-highlight">The cover letter should include:
<div class="dotted-highlight"><ul>
And I need to access The cover letter should include so I tried:
<?php
$textarea = '<div class="dotted-highlight">The cover letter should include:
<div class="dotted-highlight"><ul>';
$replacing_to = '(<div class="dotted-highlight">(.*?)\s*){2,}<ul>';
$replacing_with = '$1<ul>';
$textarea = preg_replace('#'.$replacing_to.'#', $replacing_with, $textarea);
?>
$replacing_with adds <div class="dotted-highlight"> instead of the desired text: The cover letter should include:
So the output would be:
<ul>
and Expected OUTPUT would be:
The cover letter should include: <ul>
FIDDLE:
REGEX TESTER
strip_tags($textarea, '<ul>')$2as it is the second group that is the(.*?).