I have a lot of strings that all looking similar, e.g.:
x1= "Aaaa_11111_AA_Whatiwant.txt"
x2= "Bbbb_11111_BBBB_Whatiwanttoo.txt"
x3= "Ccc_22222_CC_Whatiwa.txt"
I would like to extract the: Whatiwant, Whatiwanttoo, and the Whatiwa in R.
I started with substring(x1,15,23), but I don't know how to generalize it. How can I always extract the part between the last _ and the .txt ?
Thank you!

regextag and you'll get answers in the next 2 minutes.