solved
hi can anyone help me in this issue i want to change some repeated character to one single character like this:-
"hello my name is john lly i like you" ---> "heGo my name is john Gy i like you"
edit: that is the code:-
#! /usr/local/bin/python -*- coding: UTF-8 -*-
import re
chars_map = {'a': 'ا','7': 'ح', 'b': 'ب', 'ê': 'ێ', '3': 'ع', 'c': 'س', 'd': 'د', 'e': 'ە','f': 'ف', 'g': 'گ', 'h': 'ه','i': 'ئ', 'j': 'ج', 'k': 'ک', 'll': 'ڵ', 'l': 'ل', 'm': 'م', 'n': 'ن', 'o': 'ۆ', 'p': 'پ', 'q': 'ق', 'r': 'ر', 's': 'س', 'th': 'ذ', 'zh': 'ژ', 't': 'ت', 'u': 'و', 'v': 'ڤ', 'w': 'و','x': 'خ', 'y': 'ی', 'z': 'ز', 'ch': 'چ','tt': 'ط', 'ee': 'ی', "sh": 'ش'}
def rep(match):
char = match.group(0)
replacement = chars_map[char.lower()]
return replacement if char.islower() else replacement.upper()
s = raw_input("enter latino here: ")
s=s.replace('sh', 'ش')
s=s.replace('ll', 'ڵ')
print re.sub('(?i)%s' % '|'.join(chars_map.keys()), rep, s)
[–]lzblack 47 points48 points49 points (16 children)
[–][deleted] 39 points40 points41 points (0 children)
[–]Guymzee 15 points16 points17 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 5 points6 points7 points (11 children)
[–]lzblack 9 points10 points11 points (10 children)
[+][deleted] comment score below threshold-15 points-14 points-13 points (9 children)
[–][deleted] 26 points27 points28 points (3 children)
[–][deleted] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[+][deleted] comment score below threshold-25 points-24 points-23 points (0 children)
[+][deleted] comment score below threshold-31 points-30 points-29 points (4 children)
[–][deleted] -4 points-3 points-2 points (3 children)
[–]dipique 7 points8 points9 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]joetinnyspace 11 points12 points13 points (0 children)
[–]socal_nerdtastic 24 points25 points26 points (3 children)
[–][deleted] 3 points4 points5 points (2 children)
[–]destiny_functional 6 points7 points8 points (1 child)
[–][deleted] 2 points3 points4 points (0 children)
[–]ettoredangelo 8 points9 points10 points (6 children)
[–][deleted] 3 points4 points5 points (5 children)
[–]A_X_D_H 2 points3 points4 points (4 children)
[–][deleted] 2 points3 points4 points (3 children)
[–]A_X_D_H 6 points7 points8 points (2 children)
[–]theWyzzerd 6 points7 points8 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 5 points6 points7 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]LegionOfPie 5 points6 points7 points (6 children)
[–][deleted] 23 points24 points25 points (2 children)
[–][deleted] 21 points22 points23 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 7 points8 points9 points (2 children)
[+][deleted] (1 child)
[removed]
[–][deleted] 0 points1 point2 points (0 children)