Count overlapping matches

Count overlapping matches

2
NewbieNewbie
2

    Jul 20, 2021#1

    I have a file with a continuous set of one-digit integers. I do a search for, let's say, eight 3's in a row. When I click on Count All in the Find and Replace box, it gives me a count, but if there are nine 3's in a row, I want it to count as two matches, rather than one. Is there a way to get UltraEdit to count overlapping matches as separate matches?

    6,603548
    Grand MasterGrand Master
    6,603548

      Jul 21, 2021#2

      The counting behavior you want to have can be achieved with using the Perl regular expression search string \<3\>(?=(?:.+\<3\>){7}) which searches for a single digit 3 with a look-ahead  for a positive match only if there are seven more single digit 3 in the line. A look-ahead searches for more characters without marking/selecting them. So for each search the found string ends with the single 3 matched first making it possible to count 9 single digit 3 in a row as two occurrences of eight single digit 3.
      Best regards from an UC/UE/UES for Windows user from Austria

      18672
      MasterMaster
      18672

        Jul 21, 2021#3

        Hi,

        you can use this Perl regexp which matches all 8digit sequences of the same number.
        (\d)(?=\1{7})

        If you need to match a particular digit then replace \d with the desired number. For example
        (3)(?=\1{7})

        BR, Fleggy

        2
        NewbieNewbie
        2

          Jul 21, 2021#4

          Thanks!!