Example #1
0
def remove_space_round_hyphen_if_one_is(string):
    index = 0
    while True:
        index = string.find('-', index + 1)
        if index == -1 or index + 1 >= len(string):
            break
        if string[index - 1].isspace() and not string[index + 1].isspace():
            string = remove_char(string, index - 1)
            index = -1
            continue
        if not string[index - 1].isspace() and string[index + 1].isspace():
            string = remove_char(string, index + 1)
            index = -1
            continue
    return string
Example #2
0
def remove_space_round_slash(string):
    index = -1
    while True:
        index = string.find('/', index + 1)
        if index == -1 or index + 1 >= len(string):
            break
        if index > 0 and string[index - 1].isspace():
            string = remove_char(string, index - 1)
            index = -1
            continue
        if index + 1 < len(string) and string[index + 1].isspace():
            string = remove_char(string, index + 1)
            index = -1
            continue
    return string