Tapatalk

How to find a number with 11 digits ignoring a number with 12 digits

How to find a number with 11 digits ignoring a number with 12 digits

1

    Mar 04, 2015#1

    Hello all,
    it may odd to ask a question from you, but I'd like to know that. Please suppose I have a text file with 10 million records and each lines contain one mobile number with 12 digits. Now it looks like I have unmatched strings with 11 digits instead of 12.

    How can I find all 11 digits strings ONLY. 12 digits of mobile numbers are okay for me, but less than 12 digits are nor correct and I have to find and delete them.

    6,685587
    Grand MasterGrand Master
    6,685587

      Mar 05, 2015#2

      The Perl regular expression search string for this task is \b\d{11}(?!\d)

      \b ... word boundary, i.e. beginning of a string consisting of digits in this case.

      \d ... any digit.

      {11} ... exactly 11 times. Possible would be also {8,11} meaning minimum 8 and maximum 11 times.

      (?!\d) ... negative lookahead. The next character after the 11 (or 8 to 11) digits is NOT a digit.

      If the file contains just 1 phone number per line and nothing else, you can use for a Perl regular expression Replace All with an empty replace string the search string ^(?:(?!\d{12}).)*$(?:\r?\n|\r) to delete all lines not containing a string with exactly 12 digits. See topic how to delete all lines NOT containing specific word or string or expression?
      Best regards from an UC/UE/UES for Windows user from Austria