I have a table with a column field
that has values like Samsung Phone.
My question is how can I get this row if I search for a string \"Samsung\" or \"phone
Also you can use this:
title ~* '(^|[^\w])samsung([^\w]|$)'
The advantage of the above one is, it can be easily extended to include characters from different encoding like this: (Turkish characters)
title ~* '(^|[^\wğüşıöçĞÜŞİÖÇ])samsung([^\wğüşıöçĞÜŞİÖÇ]|$)
Here is a sample case where you may need the above extension.
For example; in a Latin5 encoded database you have a value of 'İsamsung'. İ is the capital of i in Turkish.
In this case the title ~* '(\msamsung\M)'
does not work.
This criteria returns the İsamsung value. Because in Latin5 encoding, postgre thinks İ is out of alpanumeric range and the value is something similiar to :samsung.