MySQL Forums
Forum List  »  French

Re: Requete sur champ texte complexe
Posted by: Cedric L.
Date: May 19, 2009 08:07AM

Hello,

Je vous poste ma solution au cas ou cela intéresserait du monde.
Elle prend la valeur du nombre a rechercher dans une sous requĂȘte.
Elle cree alors la regex qui est utilisee sur un autre champ.

La solution devrait fonctionner pour des nombres compris entre 0 et 99;
N'ayant pas besoin des centaines...

Cedric



SELECT t0.position, t0.number, CONCAT(t0.regexp1,t0.regexp2,t0.regexp3,t0.regexp4,t0.regexp5,t0.regexp6,t0.regexp7) AS regex
, t0.position REGEXP CONCAT(t0.regexp1,t0.regexp2,t0.regexp3,t0.regexp4,t0.regexp5,t0.regexp6,t0.regexp7) AS ISOK
FROM (
SELECT t2.number, t2.position
, CONCAT(
'(.*)?(([^0-9]'
,t2.number
,'[^0-9])|(([^0-9][0-'
, IF(t2.number<9,t2.number,'9')
,'])'
) AS regexp1
, IF( (FLOOR(t2.number/10)-1)>0 , CONCAT(
'|([1-'
, FLOOR(t2.number/10)-1
,'][0-9])'
) , '' ) AS regexp2
, IF( (t2.number-FLOOR(t2.number/10)*10)>0 , CONCAT(
'|(['
,FLOOR(t2.number/10)
,'][0-'
, (t2.number-1-FLOOR(t2.number/10)*10)
,'])'
) , '' ) AS regexp3
, ')\-(' AS regexp4
, IF( (t2.number-FLOOR(t2.number/10)*10)<9 , CONCAT(
'(['
, FLOOR(t2.number/10)
, ']['
, (t2.number+1-FLOOR(t2.number/10)*10)
, '-9])|'
) , '' ) AS regexp5
, IF( FLOOR(t2.number/10)<9 , CONCAT(
'(['
, FLOOR(t2.number/10)+1
, '-9][0-9])'
) , '') AS regexp6
,'))(.*)?' AS regexp7
FROM (
SELECT 8 AS number, '2,8-15,19-70,51' AS position
) AS t2
) AS t0

Options: ReplyQuote


Subject
Views
Written By
Posted
5188
May 18, 2009 03:20AM
Re: Requete sur champ texte complexe
4803
May 19, 2009 08:07AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.