我希望您能够提供一个正则表达式来测试文件是否具有任何扩展名。我定义它为:如果在最后一个“.”之后没有斜杠,则文件具有扩展名。这些斜杠始终是反斜杠。
这个问题需要使用正则表达式,你需要编写一个匹配规则。
我从这个正则表达式开始:
.*\..*[^\\]
这意味着
.* Any char, any number of repetitions
\. Literal .
.* Any char, any number of repetitions
[^\\] Any char that is NOT in a class of [single slash]
这是我的测试数据(不包括##,那是我的注释)
\path\foo.txt ## I only want to capture this line
\pa.th\foo ## But my regex also captures this line <-- PROBLEM HERE
\path\foo ## This line is correctly filtered out
这个问题需要使用正则表达式,你需要编写一个匹配规则。