preg_capture捕获多个正则表达式匹配

时间:2013-02-21 20:50:44

标签: mysql regex blob user-defined-functions

我对UDF函数PREG_CAPTURE有一点问题:

SELECT id_prod, id_lang, description, preg_capture('/D[[:digit:]]{4}/', description) AS Dxxxx FROM works

通过此查询,我得到[BLOB - 5 B]

但是当我在查询中使用参数时:

SELECT id_prod, id_lang, description, preg_capture('/D[[:digit:]]{4}/', description, 2) AS Dxxxx FROM 

我得到了NULL值。 Here is example of my table 如何从描述中获取所有匹配项:D0313,D0320并通过BLOB获取?

1 个答案:

答案 0 :(得分:0)

尝试转换为char:

SELECT id_prod, id_lang, description, CAST(preg_capture('/D[[:digit:]]{4}/', description)  AS CHAR(10000)) AS Dxxxx FROM works;