I would like to return the searched word including adjacent words which appear before and after the searched word using a query in SQLite. Is it possible to do this? Or should I attempt with another way?
E.g. for the below sentence (using the description column in the database table, column name is DESC):
> select DESC from TABLE_NAME where DESC like 'popular';
Which would return:
One of the most popular methods
But, I also want returned the two adjacent words "most" and "methods", like so:
most popular methods
I tried to check with REGEXP but the following are not working:
@"SELECT Desc FROM tablename WHERE LineText REGEXP '(^| )popular( |$)'"
@"SELECT LineText FROM table1 WHERE LineText REGEXP '[[:<:]popular[[:>:]'"
Can I get those with query or with other regular expression?
I think you're going about this incorrectly. You should be able to get the returned string using your
LIKEstatement, and then use the returned string to parse out the words using your templating system, or output stream.