Hello. I need a regular expression to find text files by line count. Something like
(^.*$)\n\r(^.*$)\n\r
and
(^.*$)\n\r(^.*$)\n\r(^.*$)\n\r(^.*$)\n\r
This way I can sort text files by the number of lines.
I have a script to set columns in Total commander that would display the number of lines and the average number of characters per line in text files. But it gives error 800A0005
Content = 0 : Content1 = 0
Set FSO = CreateObject("Scripting.FileSystemObject")
Size = FSO.GetFile(FileName).Size
If Size > 0 Then
Content1 = 1
With FSO.OpenTextFile(FileName)
.Skip Size : Content = .Line : .Close
End With
With CreateObject("ADODB.Stream")
.Type = 2 : .Open : .CharSet = "UTF-8"
.LoadFromFile FileName : All = .ReadText : .Close
End With : Set Reg = New Regexp
If Content > 1 Then
Reg.Global = True : Reg.Pattern = "(\r?\n){2,}"
All = Reg.Replace(Reg.Replace(All, vbNewLine), "")
Reg.Pattern = "^\r?\n|\r?\n$"
All = Reg.Replace(All, "") : Reg.Pattern = "\r?\n"
Content1 = Round(Len(Reg.Replace(All, ""))/(Reg.Execute(All).Count + 1), 0)
Else Content1 = Len(All)
End If
End If : Set FSO = Nothing
Although I suppose a regex would suffice. I ask for help from knowledgeable people.
Counting the number of rows
Moderators: Hacker, petermad, Stefan2, white