⬅︎ Back to Test static resources in Django tests
Your comment-removing regex is a bit too greedy: it will eat anything between two comments:In [10]: re.sub('<!--(.*)-->', '', '<!-- lala -->lu<!-- blah -->', re.M)Out[10]: ''fix: use the non-greedy version of *:In [11]: re.sub('<!--(.*?)-->', '', '<!-- lala -->lu<!-- blah -->', re.M)Out[11]: 'lu'
Thanks! Well spotted!
Comment
Your comment-removing regex is a bit too greedy: it will eat anything between two comments:
In [10]: re.sub('<!--(.*)-->', '', '<!-- lala -->lu<!-- blah -->', re.M)
Out[10]: ''
fix: use the non-greedy version of *:
In [11]: re.sub('<!--(.*?)-->', '', '<!-- lala -->lu<!-- blah -->', re.M)
Out[11]: 'lu'
Replies
Thanks! Well spotted!