1.findstr . 2.txt 或 Findstr "." 2.txt

2.findstr .* 2.txt 或 findstr ".*" 2.txt

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

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

5.findstr "[abcezy]" 2.txt
从文件2.txt中查找包括a b c e z y字母的字符串或行

6.findstr "[a-fl-z]" 2.txt
从文件2.txt中查找小写字符a-f l-z的字符串,但不包含g h I j k这几个字母。

7.findstr "M[abc][hig]Y" 2.txt
从文件2.txt中可以匹配 MahY , MbiY, MahY等…..

8. ^和$符号的应用
^ 表示行首,"^step"仅匹配 "step hello world"中的第一个单词
$ 表示行尾,"step<# WebPartBody #>quot;仅匹配 "hello world step"中最后一个单词

9.finstr "[^0-9]" 2.txt
如果是纯数字的字符串或者行便过滤掉,例如2323423423 这样的字符串,如果是345hh888这样的形式就不成了。

10.findstr "[^a-z]" 2.txt
同上,如果是纯字母的字符串或者行便过滤掉,例如 sdlfjlkjlksjdklfjlskdf这样的字符,如果是sdfksjdkf99999这样的形式,掺杂着数字就不成了

前面已经说过了 ".*"表示搜索的条件是任意字符,*号在正则表达式中的作用不是任何字符,而是表示左侧字符或者表达式的重复次数,*号表示重复的次数为零次或者多次。

12.findstr "^[0-9]*$" 2.txt
这个是匹配找到的纯数字,例如 234234234234,如果是2133234kkjl234就被过滤掉了。
Findstr "^[a-z]*$" 2.txt
这个是匹配找到的纯字母,例如 sdfsdfsdfsdf,如果是213sldjfkljsdlk就被过滤掉了
如果在搜索条件里没有*号,也就是说不重复左侧的搜索条件,也就是[0-9] [a-z]那只能匹配字符串的第一个字符也只有这一个字符,因为有行首和行尾的限制,"^[0-9]<# WebPartBody #>quot;第一个字符如果是数字就匹配,如果不是就过滤掉,如果字符串是 9 就匹配,如果是98或者9j之类的就不可以了。

13. "\<…\>"这个表达式的作用
echo hello world computer|findstr "\"这样的形式
echo hello worldcomputer|findstr "\" 这样的形式就不成了,他要找的是 "computer"这个字符串,所以不可以。
echo hello worldcomputer|findstr ".*computer\>"这样就可以匹配了

20 条评论:

匿名 说...

A lease option purchase is not a bad idea with the current market conditions. [url=http://www.mulberryhandbagssale.co.uk]Mulberry Bayswater Bags[/url] It bridges moments that would otherwise leave a gap in social networking - yet it is sometimes used to blow off unwanted attention from people who pester us. [url=http://www.goosecoatsale.ca]canada goose outerwear[/url] Qnkewadsb
[url=http://www.pandorajewelryvip.co.uk]pandora store[/url] Utrjfqeiw [url=http://www.officialcanadagooseparkae.com]canada goose jacket sale[/url] mtuzrgguq

匿名 说...

I enjoy what you guys are up too. This kind of
clever work and coverage! Keep up the very good works guys I've incorporated you guys to blogroll.

my blog post; ロレックスレプリカ

匿名 说...

Hello my family member! I wish to say that this article is awesome, great written and include almost all vital infos.

I would like to see extra posts like this .

Have a look at my web page: christian louboutin wedges

匿名 说...

Unquestionably consider that that you said. Your favorite reason seemed to be
at the web the simplest thing to take note of. I say to
you, I certainly get irked whilst other folks think about
worries that they plainly do not understand about.
You controlled to hit the nail upon the top and also defined out the entire thing without having side effect , other folks could take a
signal. Will probably be again to get more. Thank you

My site - シャネル バッグ

匿名 说...

Great information. Lucky me I discovered your blog by chance (stumbleupon).

I have book-marked it for later!

Here is my web-site ... シャネル バッグ

匿名 说...

Everything is very open with a very clear clarification of the challenges.
It was definitely informative. Your website is extremely
helpful. Thank you for sharing!

Here is my web-site クリスチャンルブタン

匿名 说...

Thanks for the good writeup. It actually was once
a enjoyment account it. Glance complex to far delivered
agreeable from you! However, how can we communicate?

My page :: トリーバーチ 長財布

匿名 说...

I like the helpful information you provide in your articles.
I will bookmark your blog and check again here frequently.
I am quite sure I'll learn many new stuff right here! Best of luck for the next!

Here is my site - ralph lauren outlet online

匿名 说...

I drop a comment each time I like a post on a website or I have something to contribute to the discussion.
Usually it is caused by the fire displayed in the post I looked at.
And after this article "FINDSTR正则表达式的基本用法".
I was excited enough to drop a thought :-P I actually do have
2 questions for you if you tend not to mind.

Is it only me or does it seem like some of these comments appear like they are coming
from brain dead individuals? :-P And, if you are posting on
additional sites, I'd like to keep up with everything new you have to post. Would you make a list every one of all your social pages like your linkedin profile, Facebook page or twitter feed?

My webpage; Replica Rolex

匿名 说...

Pretty nice post. I just stumbled upon your blog and wanted to say that
I have really enjoyed browsing your blog posts.

In any case I will be subscribing to your feed and
I hope you write again soon!

Also visit my web-site; Replica Rolex Watches

匿名 说...

I pay a visit day-to-day a few blogs and information
sites to read posts, except this website presents feature based posts.

Also visit my web blog: Replica Watches

匿名 说...

I loved as much as you will receive carried out right here.
The sketch is attractive, your authored material stylish.
nonetheless, you command get got an shakiness over that you wish be delivering the
following. unwell unquestionably come more formerly again since exactly the
same nearly a lot often inside case you shield this increase.

Here is my site :: Replica Rolex Watches

匿名 说...

Way cool! Some very valid points! I appreciate you writing this write-up and the rest of
the site is really good.

Take a look at my web blog ... Replica Watches

匿名 说...

It's a shame you don't have a donate button! I'd without a doubt donate to this excellent blog! I guess for now i'll settle for bookmarking and adding
your RSS feed to my Google account. I look forward to brand new updates and will share this site with my Facebook group.
Chat soon!

Here is my homepage wearproofrolexwatchs.weebly.com

匿名 说...

I have learn several just right stuff here.
Definitely worth bookmarking for revisiting.
I surprise how so much effort you place to make any such magnificent informative site.

Here is my website :: cheap ralph lauren polo

匿名 说...

Thanks for the good writeup. It in fact was once a entertainment
account it. Glance advanced to more added agreeable from you!
However, how could we keep in touch?

My site; www.miumiuoutletstore2013.com

匿名 说...

Great blog here! Also your website loads up very fast! What web
host are you using? Can I get your affiliate link to your host?
I wish my website loaded up as fast as yours lol

My web page http://www.lasallechihuahua.edu.mx/

匿名 说...

Hi, I do think this is a great blog. I stumbledupon it ;
) I will come back yet again since I book-marked it.
Money and freedom is the best way to change, may you be rich and continue to help other people.

Also visit my website; cheap ralph lauren polo

匿名 说...

Hi, I do think your blog could be having internet browser
compatibility problems. Whenever I take a look
at your website in Safari, it looks fine however when
opening in Internet Explorer, it has some overlapping issues.
I merely wanted to provide you with a quick heads up!
Besides that, wonderful blog!

Here is my homepage :: Replica Watches

匿名 说...

Howdy! This post couldn't be written any better! Reading through this post reminds me of my previous roommate! He constantly kept talking about this. I am going to forward this post to him. Pretty sure he's going
to have a great read. Thank you for sharing!

Take a look at my web-site ... Cheap Oakley Sunglasses