I would like to use regular expression to represent a pattern with the following type of characteristics1)  It includes a continuous sequence of digit values. The length of this sequence it at least 12)  There has at least one non-digit characters either before the first digit value of the above sequence, or after the last digit value of the above sequence, or both before and end.Therefore, the regular expression should be match the following examples:A123A123B#A123BNNN.123-123+On the other side,AB123B123 is beyond the scope of the above pattern, since it has two sequences of digit values there. This question does not need to consider this scenario.Hopefully, I have made this question clear.
a string representation using regex (modified)
linux;text processing;regular expression;string
This seems to do what you want using grep:$ grep -P ^\D+\d+$|^\d+\D+$|^\D+\d+\D+$ data.txtAdding additional lines to data.txt would seem to indicate that this is working per your requirements.Example$ cat data.txt &320*10-AB123-1234ABCDEFa20d3412a1232q5858j' 2323 '234aaa#A123BNNN.123-123+Sample run:$ grep -P ^\D+\d+$|^\d+\D+$|^\D+\d+\D+$ data.txt&320*10-AB123-' 2323 '234aaa#A123BNNN.123-123+If you're unfamiliar with  grep's -P switch see the reference below. The switch allows for grep to use much of hte regex engine that's available in Perl.ReferencesPCRE - Perl Compatible Regular Expressions