Regex that worked on Sublime not working on Pychar

2019-02-19 19:09发布

Ok so, in Sublime Text I can use this Find/Replace regex:

find: (src|href)="(assets\/.+?)"
replace: \1="{% static '\2' %}"

To replace this

<link href="assets/css/cssfile.css">

With this:

<link href="{% static 'assets/css/cssfile.css' %}"/>

When I use the same regexes in Pycharm, it doesn't replace the values correctly.. is it a regex problem or a Pycharm problem? I'm not sure since I'm kind of new to regular expressions.

标签: regex pycharm
1条回答
仙女界的扛把子
2楼-- · 2019-02-19 19:41

As described in the PyCharm documentation, in PyCharm you need to use $1 rather than \1 to refer to a group in the replacement expression.

查看更多
登录 后发表回答