python - Sublime Text 3 API plugin for regex replacing text -


i'm writing small plugin in sublime text 3 replace empty lines. used re module regex replace text. these codes test on console:

>>> text = 'abc \n\nok' >>> print(text) abc   ok >>> text = re.sub(r'^\n','',text) >>> text 'abc \n\nok' 

i can search on st3 ctrl+f = '^\n'. why pattern ^\n not working in plugin?

because didn't use multiline flag in code. try this:

re.sub(re.compile('^\n', re.multiline), '', s) 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -