I want to use regular expression to find strings in a file that have part of them that are non-numeric.
This would be a good string IDxxxxxx0123456789.
This would be a bad string IDxxxxxx01234?6789.
The file I am grepping has many different lines of text, and I am specifically interested in ones that conform to IDxxxxxx then I expect 10 digits. I want to find the lines where the 10 digits are not all digits.
I have this so far,
grep "ID.\{6\}[^0-9]" myFile
This works fine if the first character after the IDxxxxxx is non-numeric. So I extended this as follows;
grep "ID.\{6\}[^0-9]\{1,10\}" myFile
which I hoped would mean IDxxxxxx followed by 1 to 10 non-numeric characters. This again works if the first character is non-numeric, but not the second.
I think I must be getting close, but not close enough. Can anyone steer me a little on this one please. I shall keep at this, and if I find an answer before anyone answers then I will post what I find.
Thanks in anticipation
(Update – I want to grep out all the bad strings)
1 Answer