Answer the question
In order to leave comments, you need to log in
How is a text search performed?
How to search for matches in the text by entering the value you are looking for and clicking the search button. it is necessary that after each click on the search, it highlights the desired value, first the first and then each next.
like in wordpad
Answer the question
In order to leave comments, you need to log in
The simplest option is to use the prefix function (Knuth-Morris-Pratt algorithm). Then the search will be quite slow on large texts, but it is easy to implement.
You can use a suffix array , then searching by text will be noticeably faster, but it will require you to rebuild the suffix array every time you change the text. An option for optimization is to build it only for a search request, and for subsequent search requests (without changing the text), use the already built suffix array.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question