Question:
Regular Expression " -i " is case-intensitive, but i don't understand the meaning of phrase.?
IHSV
2007-11-19 20:01:33 UTC
Todays i have read the book of jeffrey friedl, "Mastering Regular Expression".
It is maybe a simple question for english native speaker, but i am not.

% egrep -i blabla...

Jeffrey said in his book, from above expression, "-i" means case-intensitive.
But I cannot understand, what case-intensitive means.

First I think that it means "make something intense in any case", but the expression "-i" functions "ignore uppercase and lowercase".

Can you explain the meaning of 'case-intensitive' by another way please?
Three answers:
damnyankeega
2007-11-19 20:20:41 UTC
Case insensitive means that (grep or egrep) will treat a word the same in its search whether it is capitalized or not.



For example, if you have a text file and you type "grep foo ", that means that grep will ONLY return EXACT matches to "foo". grep "FOO" will only return matches to "FOO".



grep -i, however, will return matches for "FOO", "foo", "Foo", "FOo", "fOo", etc.



Experiment with a file in which the same word is capitalized and in lowercase.
Tony D
2007-11-20 04:08:19 UTC
case-insensitive means that it doesn't care whether the expression has upper case (capital) or lower case letters - A and a are considered to be the same letter. In other words, it's not sensitive to the case (upper case or lower case) of the letters.



The opposite would be case-sensitive. With case-sensitive, A and a are two entirely different letters.



Hope this helps...
piquet
2007-11-20 04:05:19 UTC
'case insensitive' means that the command does not care whether the letter 'i' in the -i is typed in upper case (-I) or lower case (-i) - the author likely refers to this because with some command line software it IS 'case sensitive', meaning -i (lower case) is taken differently from -I (upper case).



when a software is case sensitive and you provide an argument/parameter in lower case when it is expecting it to be in upper case, it will fail - the same applies the other way round.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...