I have these 200+ character long strings stored in a file. In each string, there exists a pattern such as
# is a digit between 0 and 9 and
X is a character between A and Z in upper or lower case. Leading and trailing characters can be any printable character, including space, but other than
[A-Z]. And the length of this string is not fixed either, but no less than 180 characters, mostly more than 200.
All I need is the start location of the pattern in the longer string, like what index function in perl returns. My caveat is there is no perl on this system with no additional software installation chance.
So far what I was able to think is to start from the 1st char of the string and check if the character I get is a digit. If yes, check the second one for being a digit. So far and so on... repeat until all 12 characters are satisfied, by using cascaded if statements, and breaking out of the loop if the condition in the comparison chain returns an unsatisfactory character before we hit the count of 12.
I was wondering if there is anything can be done with regex or without, eliminating the need for 12 cascaded if statements under bash. And yes I have access to sed and awk if either will make life easier.