#C5005. Case-Insensitive Line Filter
Case-Insensitive Line Filter
Case-Insensitive Line Filter
You are given a search pattern and a list of text lines. Your task is to output all the lines that contain the search pattern, regardless of case. In other words, when checking if a line contains the pattern, treat uppercase and lowercase letters as equivalent.
Input: The input is provided through standard input. The first line contains a non-empty search pattern. The second line contains an integer n indicating the number of subsequent lines. Each of the next n lines is a string that may or may not contain the pattern.
Output: For every line from the input that contains the search pattern (in a case-insensitive manner), print that line in the same order as they appear in the input. If no line matches, print nothing.
The matching operation can be described mathematically as follows:
\( \text{match}(line, pattern) \iff \text{lower}(line) \text{ contains } \text{lower}(pattern) \)
inputFormat
The first line of the input contains a string representing the search pattern.
The second line contains an integer n, representing the number of lines that follow.
Each of the next n lines contains a string which is a line from the text file.
outputFormat
Output each line that contains the search pattern (ignoring case) on a new line. The order of output lines should be the same as the input order. If no line contains the pattern, output nothing.
## samplesearch
5
This is a simple search example.
Just another line in the file.
Trying to test the search function.
SEARCH should be case insensitive.
No match here.
This is a simple search example.
Trying to test the search function.
SEARCH should be case insensitive.
</p>