Java Counting # of occurrences of a word in a string

前端 未结 8 1830
再見小時候
再見小時候 2020-12-03 19:20

I have a large text file I am reading from and I need to find out how many times some words come up. For example, the word the. I\'m doing this line by line e

8条回答
  •  不思量自难忘°
    2020-12-03 19:55

    I think this is an area where unit tests can really help. I had a similar thing some time ago where I wanted to break a string up in a number of complex ways and create a number of tests, each of which tested against a different source string, helped me to isolate the regex and also quickly see when I got it wrong.

    Certainly if you gave us an example of a test string and the result it would help us to give you better answers.

提交回复
热议问题