PHP正则表达式以匹配字符串的最后一次出现

PHP正则表达式以匹配字符串的最后一次出现,php,regex,preg-match,preg-split,Php,Regex,Preg Match,Preg Split,我的字符串是$text1='A373R12345' 我想查找此字符串的最后一个无数字出现。 所以我使用这个正则表达式^(.*)[^0-9]([^-]*) 然后我得到了这个结果: 1.A373 2.12345 但我的预期结果是: 1.A373R (它有“R”) 2.12345 另一个例子是$text1='A373R+12345' 然后我得到了这个结果: 1.A373R 2.12345 但我的预期结果是: 1.A373R+ (它有“+”) 2.12345 我要包含最后一个无数字编号 请帮忙!!谢谢

我的字符串是
$text1='A373R12345'

我想查找此字符串的最后一个无数字出现。
所以我使用这个正则表达式
^(.*)[^0-9]([^-]*)

然后我得到了这个结果:
1.A373
2.12345

但我的预期结果是:
1.A373R
(它有“R”)
2.12345

另一个例子是
$text1='A373R+12345'

然后我得到了这个结果:
1.A373R
2.12345

但我的预期结果是:
1.A373R+
(它有“+”)
2.12345

我要包含最后一个无数字编号
请帮忙!!谢谢

$text1 = 'A373R12345';
preg_match('/^(.*[^\d])(\d+)$/', $text1, $match);
echo $match[1]; // A373R
echo $match[2]; // 12345

$text1 = 'A373R+12345';
preg_match('/^(.*[^\d])(\d+)$/', $text1, $match);
echo $match[1]; // A373R+
echo $match[2]; // 12345
对正则表达式的详细解释:

^ match from start of string
(.*[^\d]) match any amount of characters where the last character is not a digit 
(\d+)$ match any digit character until end of string

它适合我的位置!!谢谢你能给我解释一下正则表达式吗?我只知道。*[^\d]表示您希望找到最后一个数字number@crypticツ 你用过什么工具?