I have been trying to make this search engine for a MySQL database. Taking in user input is no problem, database querying is also fine.
One thing I need to figure out is this:
I am a string in the database
How do I match the input "AM", but keep the same case? There are PHP functions like str_ireplace
or preg_replace
/eregi_replace
, but what I need to do is split the string according to every exact match (as separate word, so do not match "lAMb", only "am").
That is so I may highlight the matches. Also I need to figure out how to dynamically shorten a string but keep where matches are in the middle:
... this is part of the string where ...
and do this according to font-size set by user in any browser. I had one which only worked in WebKit, but this is no good. Please answer with something like PHP or Python, I'm not a hard-core C kind of guy.