in reply to How to get substring between first and second character
Err..., a substring between two adjacent characters is always "".
Probably, not the best title chosen for your problem.
As said, a regex solves your problem easily:
while (<DATA>){ if (/^.*?\_(.*?)(CI|I)SD\_.*?$/) {print $1,"\n"} } __DATA__ my_firstmachISD_blah_blah the_secondCISD_blah_blah_blah
Updated: I need to trim the last few characters which could be either CISD or ISD
Updated again: yes, C?ISD is better than (CI|I)SD
|
|---|