human
Repeat substrings of the given String required number of times | Function that returns true if the passed character is a digit.
Function to return the next index of a non - digit character in the string starting at the index i ( returns - 1 ifno such index is found ).
If the character at index i is a digit then skip to the next character.
If no such index was found.
Function to append str the given number of times to the StringBuilder.
Function to return the string after performing the given operations.
To build the resultant string.
Index of the first non - digit character in the string.
While there are substrings that do not consist of digits.
Find the ending of the substring.
Starting index of the number.
If no digit appears after the current substring.
Find the index at which the current number ends.
Parse the number from the substring.
Repeat the current substring required number of times.
Find the next non - digit character index.
Return the resultant string.
Driver code"
Solution in Python:
 ... What is a code to repeat substrings of the given String required number of times and the other steps required?
assistant
#Here is code to repeat substrings of the given String required number of times and the other steps required.
 def isDigit ( ch ) :
	if ch >= '0' and ch <= '9' :
		return True
	return False
def nextNonDigit ( string , i ) :
	while i < len ( string ) and isDigit ( string [ i ] ) :
		i += 1
	if i >= len ( string ) :
		return - 1
	return i
def appendRepeated ( sb , string , times ) :
	for i in range ( times ) :
		sb . append ( string )
def findString ( string , n ) :
	sb = list ( )
	startStr = nextNonDigit ( string , 0 )
	while startStr != - 1 :
		endStr = startStr
		while ( endStr + 1 < n and not isDigit ( string [ endStr + 1 ] ) ) :
			endStr += 1
		startNum = endStr + 1
		if startNum == - 1 :
			break
		endNum = startNum
		while ( endNum + 1 < n and isDigit ( string [ endNum + 1 ] ) ) :
			endNum += 1
		num = int ( string [ startNum : endNum + 1 ] )
		appendRepeated ( sb , string [ startStr : endStr + 1 ] , num )
		startStr = nextNonDigit ( string , endStr + 1 )
	sb = ' ' . join ( sb )
	return sb
if __name__ == " _ _ main _ _ " :
	string = " g1ee1ks1for1g1e2ks1"
	n = len ( string )
	print ( findString ( string , n ) )