#C129. Count Substring Occurrences (Case Insensitive)
Count Substring Occurrences (Case Insensitive)
Count Substring Occurrences (Case Insensitive)
You are given a text string and a substring. Your task is to count the number of occurrences of the substring in the text string in a case-insensitive manner. In other words, the matching should ignore the case of letters.
For example, if the text string is "Python is amazing. PYTHON is versatile. python is popular." and the substring is "python", the answer should be 3.
In mathematical terms, if we let \(T\) be the text string and \(S\) be the substring, then the number of occurrences is given by:
\(\text{Count} = \text{occurrences}(\text{lower}(T),\, \text{lower}(S))\)
inputFormat
The input consists of two lines:
- The first line contains the text string.
- The second line contains the substring to search for.
Both the text string and the substring may contain spaces and punctuation.
outputFormat
Output a single integer representing the number of occurrences of the substring within the text string (case-insensitively).
## samplePython is amazing. PYTHON is versatile. python is popular.
python
3