I'm needing to search through a text file and count the occurences of a specific string within the file. For example, the file contains many occurences of "V00289441" and such. I need to count how many times "V00" appears. I have found and modified code that will allow me to type a word in and it will tell me how many times it shows up, but it is case sensitive and has to match exactly. For example, if I simple type "V00" it will count 0, but if I type the entire string "V00289441", it will count to 1. I need to it count every occurence of "V00". So if I do a search for how many times the word "Date" appears, it will only count it if it is "Date" exactly. It won't count if it finds "Date:" or "date" or "DATE". Here is the code I used to count:
Yes, I agree. I am sure I need to use a different function. This one works for what it was meant to - to count an input word - but I need something different that will let me count portions of a string. Think of it like "Search and Replace" in MS Word. If I tell it to replace "car" with "hat", it will find "car", "cart", "scar", "vicar" and make them all "hat", "chat", "shat", and "vihat". I need mine to work like this, except do a count for each time it finds the string, in this case "V00".