更新时间:2023-11-15 17:01:52
您可以将正则表达式与 preg_match
,就像这样:
You could use a regex with preg_match
, like this :
$string = "Conacu P PPL Europe/Bucharest 680979";
$matches = array();
if (preg_match('#(\d+)$#', $string, $matches)) {
var_dump($matches[1]);
}
然后您会得到:
string '680979' (length=6)
以下是一些信息:
#
是定界符-它们没有任何意义:它们仅表示正则表达式的开头和结尾;并且您可以使用任何想要的字符(人们经常使用/
)()
表示您想捕获它们之间的内容
preg_match
,作为第三个参数给出的数组将包含那些捕获的数据()
#
at the beginning and the end of the regex are the delimiters -- they don't mean anything : they just indicate the beginning and end of the regex ; and you could use whatever character you want (people often use /
)()
means you want to capture what is between them
preg_match
, the array given as third parameter will contain those captured data()
所以:
有关更多信息,请查看 PCRE模式和 Pattern Syntax
.
For more information, you can take a look at PCRE Patterns and Pattern Syntax
.