I want to capture the first 4-7 characters of a file name that come before an underscore. My current expression looks like: (\S{4,7})_
This parses out: ACCEL_Certificates of Coverage to just ACCEL, which is what I want.
However, I also want this same regular expression to accept just the file name ACCEL, with no underscore. How do I construct this to accept a file name with an underscore or without an underscore? Everything I have tried either gives me nothing or will pull ACCEL_C. I know this should be so simple, but I'm just not figuring it out. Thanks!