Created
October 14, 2014 21:05
-
-
Save ertugrulozcan/83c9b23f7e126ad0f8ab to your computer and use it in GitHub Desktop.
Programlama dilleri - Proje 2
This file contains 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
''' | |
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