标签: regex
我有一些这样的文字:
>>> secure_filename("My cool movie.mov") 'My_cool_movie.mov' >>> secure_filename("../../../etc/passwd") 'etc_passwd' >>> secure_filename(u'i contain cool \xfcml\xe4uts.txt') 'i_contain_cool_umlauts.txt'
我需要编写一个正则表达式以匹配仅在方括号内的逗号。
答案 0 :(得分:1)
使用向前看的意思是“找到的下一个方括号必须是右括号:
,(?=[^\[]*])
请参见live demo。