D
D
Dmitry Korolev2016-09-18 18:57:08
C++ / C#
Dmitry Korolev, 2016-09-18 18:57:08

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

1 answer(s)
M
Matthew Strechen, 2016-09-18
@X_Warlock

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 question

Ask a Question

731 491 924 answers to any question