如何在一段文本中找到路径和文件名?
在你标记这个问题为重复之前,我知道关于文件路径的问题已经存在。
- 用于解析目录和文件名的正则表达式(不能匹配段落)
- 匹配目录路径但不包括文件路径的正则表达式(这个只匹配文件名,答案对于段落不起作用,并且没有涉及点号或空格)
- 用于匹配文件路径的Java正则表达式(没有涉及点号或空格)
- 从路径中提取文件名的正则表达式(没有涉及段落)
例如:
In file included from /some/directoy/3.33A.37.2/something else/dogs.txt,
from /some/directoy/something else/dogs.txt,
from /some/directoyr/3.33A.37.2/something else/dogs.txt,
from /var/log/xyz/10032008.log,
from /var/log/xyz/test.c:29:
Solution:
please the file something.h has to be alone without others include, it has to be present in release letter,
in order to be included in /var/log/xyz/test.c and /var/log/xyz/test.h automatically
Other Note:
The file something.c must contain the somethinge.h and not the ecpfmbsd.h because it doesn't contain C operative code.. everything good..
以下是最理想的匹配:
/some/directoy/3.33A.37.2/something else/dogs.txt
/some/directoy/something else/dogs.txt
/some/directoyr/3.33A.37.2/something else/dogs.txt
/var/log/xyz/10032008.log
/var/log/xyz/test.c:29 (this is a tricky one, ok with out it)
/var/log/xyz/test.c
/var/log/xyz/test.h
进一步说,如果我找到了答案,如何将其更改为使用反斜杠\
而不是斜杠/
目录。
something /var/log/xyz/10032008.log
,它必须在发布信中出现,才能自动包含在/var/log/xyz/test.c:54546
中。 - Whitecat\/.*\.[\w:\s]+
,但这会破坏其他匹配。 - Federico Piazza