Skip to content

Instantly share code, notes, and snippets.

@tanbro
Last active February 20, 2019 04:01
Show Gist options
  • Save tanbro/d333271dc415ae337f1b50f9bc467660 to your computer and use it in GitHub Desktop.
Save tanbro/d333271dc415ae337f1b50f9bc467660 to your computer and use it in GitHub Desktop.
Remove line seperator in a text
"""
Remove line seperator in a text
"""
import re
REMOVE_LINESEP_RE = re.compile(r'(?P<c>[\S])([\r|\n]+)')
def remove_linesep(s): # type: (str)->str
return re.sub(REMOVE_LINESEP_RE, r'\g<c>', s.strip())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment