Every line of 'python split string by character count' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
113 def split(string, char): 114 """ Split a string with a char and return always two parts""" 115 string_list = string.split(char) 116 if len(string_list) == 1: 117 return None, None 118 return char.join(string_list[:-1]), string_list[-1]
7 def split_string(s, n): 8 return [s[i*n:i*n+n] for i, j in enumerate(s[::n])]
361 def splitOnCap(string): 362 """Splits a string into words based on capitalisation whilst preserving 363 acronyms 364 """ 365 split = re.sub( r"([A-Z])", r" \1", string).split() 366 newString = "" 367 for i in range(len(split)): 368 if len(split[i]) == 1 and len(split[i-1]) == 1: 369 newString += split[i] 370 else: 371 newString += " " + split[i] 372 return newString
59 @register.function 60 def char_split(value, names=None, char="$"): 61 value_list = value.split(char) 62 63 if names is not None: 64 return dict(zip(names, value_list)) 65 66 return value_list
476 def _split(self, string): 477 start_index, max_index = self._find_variable(string) 478 self.start = start_index 479 self._open_curly = 1 480 self._state = self._variable_state 481 self._variable_chars = [string[start_index], '{'] 482 self._list_variable_index_chars = [] 483 self._string = string 484 start_index += 2 485 for index, char in enumerate(string[start_index:]): 486 index += start_index # Giving start to enumerate only in Py 2.6+ 487 try: 488 self._state(char, index) 489 except StopIteration: 490 return 491 if index == max_index and not self._scanning_list_variable_index(): 492 return
126 def split_string(input_string): 127 '''Split a string to a list and strip it 128 :param input_string: A string that contains semicolons as separators. 129 ''' 130 string_splitted = input_string.split(';') 131 # Remove whitespace at the beginning and end of each string 132 strings_striped = [string.strip() for string in string_splitted] 133 return strings_striped