小编rya*_*461的帖子

当正则表达式工具表明它应该时,python正则表达式不匹配

我在脚本中有一个if语句,以查看通过argparse给出的目录是否是UNC路径.但不会以尾随斜线结束.

import re

#dest is set by argparse. but for this purpose i'll set it manually.
#originally i was escaping each \ in dest. But I found that argparse left them alone.
dest = '\\server-name\folder\subfolder'

if re.match ('^\\+[\w\W]+', dest ) and not re.match( '^\\+[\w\W]+\\$', dest):
    dest = dest + '\\'
Run Code Online (Sandbox Code Playgroud)

我一直在用ipython玩这个.第一个声明无法匹配.我在Komodo IDE中使用了RxToolkit,它将正则表达式显示为匹配.我试过这个webtool:http://www.pythonregex.com/ 也匹配.有任何想法吗?

python regex

3
推荐指数
1
解决办法
57
查看次数

标签 统计

python ×1

regex ×1