你能解释一下这个preg_match代码在做什么! 我也不明白为什么以#tag开头?
if (!preg_match('#\.(.+)$#', $file['name'][$key], $matches)) {..;}
答案 0 :(得分:0)
首先,它测试正则表达式 DOESN' T MATCH (!preg_match
)以下内容:
#\.(.+)$#
---------
Match the character “#” literally «#»
Match the character “.” literally «\.»
Match the regex below and capture its match into backreference number 1 «(.+)»
Match any single character that is NOT a line break character (line feed) «.+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Assert position at the end of a line (at the end of the string or before a line break character) (line feed) «$»
Match the character “#” literally «#»
我无法帮助$file['name'][$key]
,因为我不知道它是什么,它似乎是filename
。