I am trying to do search for patterns in MYSQL on some unstructured text fields, based on notes from employees that vary based on different data entry styles. Data entry might record the following for caffeine use:
User 1: 'Caffeine: Never'
User 2: 'Caffeine - Not much'
User 3: 'Caffeine: No'
User 4: 'Caffeine-No'
I am trying to find a way to search all records where it says "Caffeine" + (1 or more space OR no space) + (: OR - OR no character) + (1 or more space OR no space) + (NOT anything starting with 'N')
What I have tried is:
select * from table where text RLIKE [[:space:]][[:punct:]][[:space:]]*[^nN]';
The first part of the expression seems to work, but I'm finding exceptions in the result for the last part, excluding "n" or "N", and I'm not sure why my query isn't excluding. I'm hopeful this is something somebody can help clarify here.