Forum Moderators: coopster
For example, if I have the following comma-delimited list of categories in a mysql db field:
gameboy, nintendo, playstation
and I do a search, I know I can use regexp to do something like:
select * from categories where regexp 'gameboy,'
Notice that I have the comma in there to match the whole word and the comma without matching part of a word (to prevent unwanted matches such as "play" to "playstation" or "game" to "gameboy").
The problem I'm running into is words that match that match the end of each word next to the comma (in this example, "boy" and "station").
What's the right way to match a word *exactly* using regexp *without* also matching *part* of a word. Don't need the specifics, but some guidance would be great.
TIA
(?<,¦^)\s*([^,]*?)\s*(?=,¦$)
This means match a string that is preceeded by the beginning of the subject OR a comma, then any amount of whitespace, then a string that does not include a comma (lazy, so we don't catch traling whitespace) then any amount of whitespace and then followed by either a comma or the end of hte subject.
SN