I am creating an automatic completion, and I have a slight problem with highlighting the results. You see, my search algorithm is very generous and ignores apostrophes as a result, so a query like joes
will match Joe's
. The search algorithm will take care, and now there is a selection. I wanted to make the offset pattern bold.
Let's say I had the original unformatted result: Joe's
(pay attention to rsquo \ u2019), and I wanted to distinguish it as follows: Joe’s
for the following queries by joes
, Joe's
and Joe's
(rsquo \ u2019)
In the question, I included a single quotation mark on the right side, because you don’t know if anyone has copied the query from a Word document or something like that.
I could easily do this by ignoring the fact that quotation marks are present in both search / result lines, but it will ruin the entire search point when you accidentally type something like joes'
or even worse jo'es
, so I somehow you need to keep the quote position. Also note that the apostrophe can also be anywhere in the unformatted result string like this: Suq'Ata
.
The following is a list of scenarios:
- String:
Liliana's
- Requests:
lilianas
, Liliana's
- Result:
Liliana's
- String:
Suq'Ata
- Requests:
suqat
, suq'at
- Result:
Suq'At a
- String:
Telim'Tor's
- Requests:
telimt
, telim't
- Result:
Telim'T or's
It should be noted that the position of quotation marks in the request is important, whereas if the quote is incorrect in the request, it should not coincide. So you have the correct quote position or no quotes at all to highlight the original string.
In fact, I do not mind if the proposed solution is to split each letter and break through it (thought about it), since I will do this up to 5 lines at a given time. I look forward to your suggestions!
source share