Problem looks easy. I havent issue like this in other languages, I cant find reason. PythonScript for Notepad++:
non-greedy html comment removal for entity:
<!-- <input id="file_upload" type="file"/> --> ass -->
python script: (?P<begin> and ?P<end> group names are for clearness)
import re
line = editor.getCurLine()
p = re.compile('(?P<begin><!--+)(?P<between>.*?)(?P<end>--+>)')
if '<!--' in line or '-->' in line:
console.write(p.sub(r'\g<between>', line))
else:
console.write('not commented.. ' + line)
results:
<input id="file_upload" type="file"/> ass -->
works satisfactorily.
but if I want to implement conditional (?) / {0,1} occurrences for <begin> or <end>:
1) '(?P<begin><!--+)?(?P<between>.*?)(?P<end>--+>)?'
2) '(<!--+)?(?P<between>.*?)(--+>)?'
the result looks GREEDY/or replaced in all occurences.. count=x flag wont help - disables replacements at all.
other pattern tryings with similar result is failing too:
3) '(<!--+){0,1}(?P<between>.*?)(--+>){0,1}' replacement = r'\g<between>'
4) '(<!--+)?(?:.*?)(--+>)?' replacement = ''
5) '(?:<!--+)?(.*?)(?:--+>)?' replacement = '\\1'
all results are:
<input id="file_upload" type="file"/> ass
(last '-->' should stood). any clue?