こんにちは、私はこれを解決できる人を見つけることができると確信しています..
この文字列から「2013 年 4 月 21 日」という値を取得しようとしています。
$string = "Issue Date: Sunday April 21, 2013 / week 10/2003week 11/2003week 12/2003week 13.."
前もって感謝します...
正規表現は必要ありません:
$string = 'Issue Date: Sunday April 21, 2013 / week 10/2003week 11/2003week 12/2003week 13..';
$array = explode(' ',$string);
$date = $array[3] . ' ' . $array[4] . ' ' . $array[5];
echo $date;
preg_match()
次の正規表現で使用し/^Issue Date: [A-z]+ (.*) \//
ます。
// prepare string and pattern
$string = 'Issue Date: Sunday April 21, 2013 / week 10/2003week 11/2003week 12/2003week 13..';
$pattern = '/^Issue Date: [A-z]+ (.*) \//';
// exec regex and check for results
if(!preg_match($pattern, $string, $matches)) {
die('the pattern was not found');
}
// output the results:
$date = $matches[1];
echo $date; // output: 'April 21, 2013'
最初に表示されるもの ("Issue Date: " の後) を探している場合は、次のように動作します。
Issue Date: (.*) /