Skip to content

Instantly share code, notes, and snippets.

@ertugrulozcan
Created October 14, 2014 21:05
Show Gist options
  • Save ertugrulozcan/83c9b23f7e126ad0f8ab to your computer and use it in GitHub Desktop.
Save ertugrulozcan/83c9b23f7e126ad0f8ab to your computer and use it in GitHub Desktop.
Programlama dilleri - Proje 2
'''
Created on 14 Ekim 2014
@author: Ahmet Ertugrul Ozcan
'''
# -*- coding: cp1254 -*-
from builtins import str
class ExtendedString(str):
def ReplaceUnderscoreWithSpace(self):
length = len(self)
if(length == 1):
return self
listOfString = list(self)
i = 1
while(i < length -1 ):
if(listOfString[i] == "_" and listOfString[i-1].isalpha() and listOfString[i+1].isalpha()):
listOfString[i] = " "
i += 1
return ''.join(listOfString)
text = ExtendedString("foo_bar_ x").ReplaceUnderscoreWithSpace()
print(text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment