Ben okuyan bir metin başlığı var
This User "The Title Of The Post"
Ben sadece tırnak içinde nedir kapmak ve bir değişkende saklamak istiyorum. Nasıl bu regex ve php ile yapmak istiyorsunuz?
http://www.php.net/preg%5Fmatch
<?php
$x = 'This User "The Title Of The Post"';
preg_match('/".*?"/', $x, $matches);
print_r($matches);
/*
Output:
Array
(
[0] => "The Title Of The Post"
)
*/
?>
$string = 'This user "The Title Of The Post"';
$its_a_match = preg_match('/"(.+?)"/', $string, $matches);
$whats_inside_the_quotes = $matches[1];
Başarılı bir eşleşme yapılmış ise $its_a_match
, aksi 0
, 1
olacaktır. $whats_inside_the_quotes
regex parantez kümesinde eşleşen dize içerir.
Durumda (o) biraz belirsiz, preg_match() aslında $matches
(üçüncü argüman) bir değer verir.