来自String的最后一个大写字

时间:2017-07-25 10:27:32

标签: php regex

我想要字符串

中的大写单词

WORDA - WORDB - WORDC - Failure occurring to be verified if a WORDD WORDE is linked to the failure.

我想要的上述字符串的预期输出是这样的:

WORDD WORDE

1 个答案:

答案 0 :(得分:1)

尝试:

<?php
$a= "WORDA - WORDB - WORDC - Failure occurring to be verified if a WORDD WORDE is linked to the failure.";
$b= '/([A-Z|\s\0-9]+)[a-z|\W\|0-9]*$/';
preg_match($b, $a, $c, PREG_OFFSET_CAPTURE);
print_r($c[1][0]);
?>