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 FINDSTR regular expressions

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article is about how to batch FINDSTR regular expressions. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

1.findstr. 2.txt or Findstr "." 2.txt

Find any character from the file 2.txt, excluding empty characters or blank lines

2.findstr. * 2.txt or findstr ". *" 2.txt

Find any characters, including blank lines and empty characters, from the file 2.txt

3.findstr "[0-9]" 2.txt

Look for a string or line that includes the number 0mur9 from the file 2.txt

4.findstr "[a-zA-Z]" 2.txt

Find a string or line that includes any character from the file 2.txt

5.findstr "[abcezy]" 2.txt

Find a string or line that includes the a b c e z y letter from the file 2.txt

6.findstr "[a-fl-z]" 2.txt

Look for the string for the lowercase character amurf lmerz from the file 2.txt, but does not contain the letters g h I j k.

7.findstr "M [abc] [hig] Y" 2.txt

From the file 2.txt, you can match MahY, MbiY, MahY, etc. ..

8. Application of ^ and $symbols

^ indicates the beginning of the line, and "^ step" matches only the first word in "step hello world"

$indicates the end of the line, and "step$" matches only the last word in "hello world step"

9.finstr "[^ 0-9]" 2.txt

If it is a pure numeric string or line, it will be filtered out, such as 2323423423, but not in the form of 345hh888.

10.findstr "[^ a Merz]" 2.txt

As above, if it is a pure letter string or line, it will be filtered out. For example, a character such as sdlfjlkjlksjdklfjlskdf will not be mixed with numbers if it is in the form of sdfksjdkf99999.

The role of number 11.*

As mentioned earlier, ". *" indicates that the search condition is any character, and the role of the * sign in a regular expression is not any character, but the number of repetitions of the left character or expression, and the * sign indicates zero or more repetitions.

12.findstr "^ [0-9] * $" 2.txt

This is the pure number found by the match, such as 234234234234, which is filtered out if it is 2133234kkjl234.

Findstr "^ [a Merz] * $" 2.txt

This is the pure letter found by the match, such as sdfsdfsdfsdf. If it is 213sldjfkljsdlk, it will be filtered out.

If there is no * sign in the search condition, that is, do not repeat the search condition on the left, that is, [0-9] [a Rizz], then only this character can match the first character of the string. Because of the restrictions on the beginning and end of the line, the first character of "^ [0-9] $" matches if it is a number, if not, it is filtered out. If the string is 9, it matches. Not if it's 98 or 9J or something like that.

13. The function of the expression "\"

This means to find a string precisely, and\ indicates the end position of the word.

Echo hello world computer | findstr "\"

Echo hello worldcomputer | findstr "\" is not good. He is looking for the string "computer", so it is not allowed.

Echo hello worldcomputer | findstr ". * computer\ >" so it can be matched.

Thank you for reading! This is the end of this article on "how to use batch FINDSTR regular expressions". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

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