I am working with some very large flat text files and I need to be able to search the file for 2 bits of text at different positions in the line of data then return how many lines contain these 2 bits of text.
So for example I want to know how many lines in the file has the word "bob" where "b" is position 1, "o" is position 2 and "b" is position 3. then in the same line I need to also find "sam" at position 30,31 & 32. I only want to count the row if both elements are present and in the correct positions.
The dot after bob is a wildcard that matches any character, and we will match exactly 26, which pushes sam out to column 30 (1 + 3 + 26). Obviously the more precise you can get about the match, the better. For instance, not knowing what else might be on the line, this particular regex will match sam or samuel as long as it starts in column 30.