regex for finding file paths

前端 未结 3 1744
孤街浪徒
孤街浪徒 2021-01-19 07:51

I used this regex(\\/.*\\.[\\w:]+) to find all file paths and directories. But in a line like this \"file path /log/file.txt some lines /log/var/file2.txt

3条回答
  •  孤街浪徒
    2021-01-19 08:05

    You can use python re

    something like this:

    import re
    msg="file path /log/file.txt some lines /log/var/file2.txt"
    matches = re.findall("(/[a-zA-Z\./]*[\s]?)", msg)
    print(matches)
    

    Ref: https://docs.python.org/2/library/re.html#finding-all-adverbs

提交回复
热议问题