I am using MySQL 5.5.
I have a table named nutritions, having a column serving_data with text datatype.
Some of the values in serving_data column are like:
[{"label":"1 3\/4 cups","unit":"3\/4 cups"},{"label":"1 cups","unit":"3\/4 cups"},{"label":"1 container (7 cups ea.)","unit":"3\/4 cups"}]
Now, I want to find records containing serving_data like 1 3\/4 cups .
For that I've made a query,
SELECT id,`name`,`nutrition_data`,`serving_data`
FROM `nutritions` WHERE serving_data REGEXP '(\d\s\\\D\d\scup)+';
But is seems not working.
Also I've tried
SELECT id,`name`,`nutrition_data`,`serving_data`
FROM `nutritions` WHERE serving_data REGEXP '/(\d\s\\\D\d\scup)+/g';
If I use the same pattern in http://regexr.com/ then it seems matching.
Can anyone help me?
\dwith[0-9]and\Dwith[^0-9]and\swith[[:space:]]. TryWHERE serving_data REGEXP '([0-9]+[[:space:]])?[0-9]+/[0-9]+[[:space:]]+cup';. See regex101.com/r/sO8fL3/1/.../g. Use the pattern only. BTW, are the\really in the string, or not? I believe there are no\s, right?name,nutrition_data,serving_dataFROMnutritionsWHERE serving_data REGEXP '[0-9][[:space:]]/[^0-9][0-9][[:space:]]cup'; - Seems not working. Yes\is there in the string.\is there, you needREGEXP '([0-9]+[[:space:]]+)?[0-9]+\\\\/[0-9]+[[:space:]]+cup';See regex101.com/r/sO8fL3/2[{"label":"1\/2 cup","unit":"cup"},{"label":"1 cup","unit":"cup"}]are also gets selected with the said pattern. I want only records like1 3\/4 cupsget selected with pattern.