Skip to content

Instantly share code, notes, and snippets.

Created June 4, 2016 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1460ad8f852cb624c17a8dec62dd3146 to your computer and use it in GitHub Desktop.
Save anonymous/1460ad8f852cb624c17a8dec62dd3146 to your computer and use it in GitHub Desktop.
Pythonオレメモ >>151 インデントを全角スペースに
# -*- coding: utf-8 -*-
'''
先頭インデントを全角スペースへ変換
'''
import sys
import re
for line in sys.stdin:
line = line.rstrip()
ma = re.match(r'^( +)(.*)', line)
if ma:
line = '  ' * (len(ma.group(1)) // 4) + ma.group(2)
else:
ma = re.match(r'^(\t+)(.*)', line)
if ma:
line = '  ' * len(ma.group(1)) + ma.group(2)
print(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment