Searching Text:- Case Sensitivity

Background

As I looked through a generated file, I was a bit perplexed as to why some matches were missing.

Code

I went back and looked at the code I was using to generate the file, it looked OK.

Yet, at the back of my mind, I am sorry that I did not follow up on the StackOverfow Q/A post that was surprisingly detailed as to why the API that I was using might not identify all of the matches.

Text File

Why cry over spilled milk.

I went back and looked at the generated file.

Sample Text File

GUI

Text


Tony
Anthony
Tone Loc
tony 
toni 
tone

 

Find Text

Platform

Platform – MS Windows

Command – Find
Syntax

find [specified-string] [file]

Sample – Default

find "tony" namelist.txt

Output – Text

>find "tony" namelist.txt

---------- NAMELIST.TXT
tony

Output – Image

Explanation

A single tony is found.

Sample – Case Insensitive

find /I "tony" namelist.txt

Output – Text

>find /I "tony" namelist.txt

---------- NAMELIST.TXT
Tony
tony

Output – Image

Explanation

Both Tony and tony are found!

Command – Findstr
Syntax

findstr [specified-string] [file]

Sample – Default

findstr "tony" namelist.txt

Output – Text

>findstr "tony" namelist.txt

tony

Output – Image

Explanation

A single tony is found.

Sample – Case Insensitive

findstr /I "tony" namelist.txt

Output – Text

>findstr /I "tony" namelist.txt

---------- NAMELIST.TXT
Tony
tony

Output – Image

Explanation

Both Tony and tony are found!

Platform – Linux

Command – grep
Syntax

grep [specified-string] [file]

Sample – Default

grep "tony" namelist.txt

Output – Text

>grep "tony" namelist.txt
tony
>
Output – Image

Explanation

A single tony is found.

Sample – Case Insensitive

grep -i "tony" namelist.txt

Output – Text

>grep -i "tony" namelist.txt
Tony
tony
>

Output – Image

Explanation

Both Tony and tony are found!

 

Listening

Listening to one of the greatest New Yorkers of them all.

Paul Simon.

Graceland did it for me.

But, way before that, there was Simon and Garfunkel.

Mrs. Robinson.

But, then that was back in 68.

Jesus loves you more than you will know
Whoa, whoa, whoa
God bless you, please, Mrs. Robinson
Heaven holds a place for those who pray

Here listening to:-

Album:- Still Crazy After All These Years
Song:- 50 Ways to leave your Lover
Channel:- Simon & Garfunkel
Link

Like Paul, the problem was just inside my head.

I was misconstruing the data.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s