I want to search for a specific string can anyone tell me why I am seeing below result? I checked it out in an Online regex site, It seems I have seperated in to 3 groups and now the result is printing the 3 groups. how I can only seperate the first group?
Also is it possible to change the code so the "String" with lower case would be detected?
Relative String
DD-JSH-String43423213-3774
DE-String43423214-SDC-3721
Output:
'String43423213', 'String', '43423213','String43423214', 'String', '43423214'
Code:
matches = re.findall(r'((String)(\d+))', inp)
matches = [j for sub in matches for j in sub if j != ""]
Expected Result:
'String43423213', 'String43423214'