Örneğin, metin için Mon 01/01/2010 01:00:00 some other text followed
, ben sadece tarih bölümünü maç için istiyorum, bu yüzden aşağıdaki PHP kodu kullanabilirsiniz
$text = 'Mon 01/01/2010 01:00:00 some other text followed';
$pattern = '/(Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s(0-9\/)+?.*/';
preg_match($pattern, $text, $matches);
$date = $matches[2];
Biz $matches[1]
yerine birlikte tarih segment böylece, eşleşen gruplarında ilk parantezli dizilimi (bu örnekte hafta segmentin gün) dahil etmek mümkün değil midir $matches[2]
? Sanırım regex desen şey ayarlayarak bunu yapabilirsiniz ama ben cevabı google olamazdı hatırlıyorum.