Created
February 12, 2009 22:45
-
-
Save sneeu/62919 to your computer and use it in GitHub Desktop.
Replace several characters with ligatures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import re | |
_REPLACEMENTS = ( | |
('ffi\B', 'ffi', ), | |
('ff\B', 'ff', ), | |
('fi\B', 'fi', ), | |
('fl\B', 'fl', ), | |
) | |
def ligature(text): | |
for pattern, replacement in _REPLACEMENTS: | |
p = re.compile(pattern) | |
text = p.sub(replacement, text) | |
return text | |
if __name__ == '__main__': | |
import sys | |
lines = '\n'.join(sys.stdin.readlines()) | |
print ligature(lines) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment