The a.txt file is as follows:
Aaaaaaa AAAA bbbbbb ccccccccccc dddd
AA aaaaaaa bbbbbbbbbb cccccccccc ddddddddddddd Eeeeeee
Aaaaaaaaaaaa bbbbbbbbbbbbb cccccccccccccccccccc
Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Aaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbb
Aaaaaaaaa ccccccccc bbbbbbbbbbbbbbb ddddddddddddddddddd
Find the rows with the largest number of characters (excluding spaces) in the text in batch and output them. It is obvious that the contents are copied to the clipboard.Code:
Aaaaaaaaa ccccccccc bbbbbbbbbbbbbbb ddddddddddddddddddd
Requirements:
1. Do not generate temporary files
2. The code is concise, efficient, and versatile.
3. the bonus points are still based on ideas.
Shimo:Copy codeThe Code is as follows: @ echo off
Setlocal enabledelayedexpansion
Set n = 0
For/F "delims =" % I in (a.txt) Do (
Set "Ke = % I"
Set ke1 =! KE: =!
Set M = 0
Call: 1
)
Echo % Wang %
Pause
Goto: EOF
: 1
If not "! Ke1 :~ % M %, 1! "=" "Set/a m + = 1 & GOTO 1
If % m % gtr % N % set n = % m % & set Wang = % ke %
Goto: EOF
BATMAN:Copy codeThe Code is as follows: @ echo off
Set num = 0
For/F "delims =" % I in (a.txt) do set "str = % I" & call, set "str = % STR :=% %" & call: LP "% I"
Call, Echo % _ % num % characters
Pause> NUL & Goto: EOF
: Lp
Set "str = % STR :~ 1% "& set/a n + = 1
If defined STR goto lp
If % N % geq % num % set "num = % N %" & set "_ % num % = % ~ 1"
Set "n = 0"