matching a specific substring with regular expressions using awk
I'm dealing with a specific filenames, and need to extract information from them. The structure of the filename is similar to: "20100613_M4_28007834.005_F_RANDOMSTR.raw.gz" with RANDOMSTR a string of max 22 chars, and which may contain a substring (or not) with the format "-W[0-9].[0-9]{2}.[0-9]{3}". This substring also has the unique feature of starting with "-W". The information I need to extract is the substring of RANDOMSTR without this optional substring. I want to implement this in a bash script, and so far the best option I found is to use gawk with a regular expression. My best attempt