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

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -