I need to create regular expression for:
<span class="myClass">some text 1</span>some text under 1<span class="myClass">some text 2</span>some text under 2<span class="myClass">some text 3</span>some text under 3
How i can get into array all text
some text n
and
some text under n
using preg_match_all
class of span is knowing
tnx
Based on your sample:
Raw Match Pattern:<span class="myClass">(.*?)</span>\r\n(.*?)(?:\r|$)
PHP Code Example: <?php $sourcestring="your source string"; preg_match_all('#<span class="myClass">(.*?)</span>\r\n(.*?)(?:\r|$)#',$sourcestring,$matches); echo "<pre>".print_r($matches,true); ?>
$matches Array:( [0] => Array ( [0] => <span class="myClass">some text 1</span>some text under 1 [1] => <span class="myClass">some text 2</span>some text under 2 [2] => <span class="myClass">some text 3</span>some text under 3 ) [1] => Array ( [0] => some text 1 [1] => some text 2 [2] => some text 3 ) [2] => Array ( [0] => some text under 1 [1] => some text under 2 [2] => some text under 3 ))
Soory, but it isn`t work if:
1. \r\n not exists in text
2. if another HTML tags exists in "some text under n"
<span class="xpert">some text 1. </span></p><p>some text under 1<br><span class="xpert">....
it may looks like this :(