I have a cell of a couple of thousand strings that contain one or more underscores as shown below:
cel={'ABC_D234_567','ABD_X157_224','PT_D204_157','PT_O268_578','DTA_P2345','CBDRT_X345_D325};
I need to extract all the letters before the first underscore and one letter after; for example, 'ABC_D', 'PT_O', or 'CBDRT_X'.
I figured out a way to do so by using strfind, but it's several lines of code; finding indices for all underscores, using only the indices for the first underscores, then extracting strings from 1 to (index+1).
I'm pretty sure one can do this in one or fewer lines; something like:
cel_new = regexe(cel,'something something','once','match');
What would this 'something something' be?