Dize ayrıştırma için PHP Regex Yardım

0 Cevap php

Ben aşağıdaki gibi bir dizesi vardır:

Are you looking for a quality real estate company? 

<s>Josh's real estate firm specializes in helping people find homes from          
[city][State].</s>

<s>Josh's real estate company is a boutique real estate firm serving clients 
locally.</s> 

In [city][state] I am sure you know how difficult it is
to find a great home, but we work closely with you to give you exactly 
what you need

Ben bu paragraf <s> </s> etiketlere dayalı bir diziye bölmek istiyorum, bu yüzden sonuç olarak şu dizi var:

[0] Are you looking for a quality real estate company?
[1] Josh's real estate firm 
    specializes in helping people find homes from [city][State].
[2] Josh's real estate company is a boutique real estate firm serving clients 
    locally.
[3] In [city][state] I am sure you know how difficult it is
    to find a great home, but we work closely with you to give you exactly 
    what you need

Bu benim şu anda kullandığım bir regex olduğunu:

$matches = array();
preg_match_all(":<s>(.*?)</s>:is", $string, $matches);
$result = $matches[1];
print_r($result);

Ama bu bir tek <s> </s> etiketleri arasında bulunan metni içeren bir dizi döndürür, bu etiketleri önce ve sonra bulunan metni yok sayar. (Yukarıda örnekte sadece dizi elemanları 1 ve 2 dönecekti.

Herhangi bir fikir?

0 Cevap