Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use batch processing to find the text line with the largest number of characters

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "how to use batch processing to find the lines of text with the largest number of characters". The content is simple and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn the article "how to use batch processing to find the lines of text with the largest number of characters".

The text a.txt is as follows:

Aaaaaaa aaaa bbbbbb ccccccccccc dddd

Aa aaaaaaa bbbbbbbb cccccccccc ddddddddddddd eeeeeee

Aaaaaaaaaaaa bbbbbbbbbbb cccccccccccccccccccc

Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa

Aaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbb

Aaaaaaaaa ccccccccc bbbbbbbbbbbbb ddddddddddddddddd

Using batch processing to find the lines with the largest number of characters (excluding spaces) in the text and output, it is obvious to copy the content to the clipboard code:

Aaaaaaaaa ccccccccc bbbbbbbbbbbbb ddddddddddddddddd

Request:

1 do not generate temporary files

2 simple code, high efficiency and good versatility

3 bonus points are still focused on thinking.

Shallow silence:

The code is as follows:

@ echo off

Setlocal Enabledelayedexpansion

Set nasty 0

For / f "delims="% I in (a.txt) do (

Set "ke=%%i"

Set KLBG: =!

Set massif 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:

The 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%%% num% characters

Pause > nul&goto: eof

: lp

Set "str=%str:~1%" & set / a natives 1

If defined str goto lp

If n geq num% set "num=%n%" & set "_% num%=%~1"

Set "nasty 0"

The above is all the contents of the article "how to find the lines of text with the largest number of characters in batch processing". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report