If you are running MySQL 8.0, you can use REGEXP_REPLACE()
twice, like:
REGEXP_REPLACE(REGEXP_REPLACE(x, '2019-11-[0-9]{2},*', ''), ',$', '')
Demo on DB Fiddle:
WITH t AS (
SELECT '2019-10-01,2019-10-03,2019-10-07,2019-10-09,2019-11-15,2019-11-17' x
UNION ALL SELECT '2019-10-01,2019-11-17,2019-10-07'
)
SELECT x, REGEXP_REPLACE(REGEXP_REPLACE(x, '2019-11-[0-9]{2},*', ''), ',$', '') x2 FROM t;
| x | x2 |
| ----------------------------------------------------------------- | ------------------------------------------- |
| 2019-10-01,2019-10-03,2019-10-07,2019-10-09,2019-11-15,2019-11-17 | 2019-10-01,2019-10-03,2019-10-07,2019-10-09 |
| 2019-10-01,2019-11-17,2019-10-07 | 2019-10-01,2019-10-07 |
Here is another option with a unique call to REGEXP_REPLAE()
:
REGEXP_REPLACE(x, '(2019-11-[0-9]{2},*)|(,*2019-11-[0-9]{2})', '')
Demo on DB Fiddle