Using regular expression in MySQL to search for an exact number in a list of numbers

— This example searches for the exact number 23 in a list of numbers — under the “ids” key in a JSON object stored as a string. — Ensure collation of connection is same as database else setting of user — variables may yield “Illegal mix of collations” error, especially if — database uses case-sensitive …

Regex to match unescaped characters only

Problem: Find key-value pairs separated by : but ignore escaped colons, i.e. \:. Solution: Negative lookbehinds – see Regex Tutorial – Lookaheads and Lookbehinds. “Positive” means “must match”, “Negative” means “must not match”. Over here, we are “looking behind” the backslash to ensure that a colon is not matched. Single match in a string: <?php …