You can use re.sub with pattern [^_]* that match any sub-string from your text that not contain _ and as re.sub replace the pattern for first match you can use it in this case :
>>> s="ID12345678_S3_MPRAGE_ADNI_32Ch_2_98_clone_transform_clone_reg_N3Corrected1_mask_cp_strip_durastripped_N3Corrected_clone_lToads_lesions_seg"
>>> import re
>>> re.sub(r'([^_]*).*',r'\1',s)
'ID12345678'
But if it could be appear any where in your string you can use re.search as following :
>>> re.search(r'ID\d+',s).group(0)
'ID12345678'
>>> s="_S3_MPRAGE_ADNI_ID12345678_32Ch_2_98_clone_transform_clone_reg_N3Corrected1_mask_cp_strip_durastripped_N3Corrected_clone_lToads_lesions_seg"
>>> re.search(r'ID\d+',s).group(0)
'ID12345678'
But without regex simply you can use split() :
>>> s.split('_',1)[0]
'ID12345678'
re.sub(r'_\w+_\d_\d+_\w+','')won't do anything at all -- you need 3 arguments -- and if you wantre.match, the second argument should be your long input string, not an empty string. Also, ifsis your long input string, a naive solution would be simplys[0:10]ors[0:s.find('_')].re.match(if the string is guaranteed to be at the start of the input) orre.searchotherwise, notre.sub-- provided, at least, you're not trying to do in-line replacement in a much longer string.