Remplacer avec des caractères génériques

Signaler
Messages postés
11
Date d'inscription
lundi 4 octobre 2004
Statut
Membre
Dernière intervention
27 janvier 2016
-
Messages postés
11
Date d'inscription
lundi 4 octobre 2004
Statut
Membre
Dernière intervention
27 janvier 2016
-
Bonjour,

Je voudrais modifier une série de variables du genre

R12012013@GTV#0 en GTV

Pour ça je fais :

SELECT essaiReplace.Texte, Replace(Replace(Replace(Replace(Replace([Texte],"R1",""), "R2",""),"1",""),"2","") ,"0","")AS Phase
FROM essaiReplace
WHERE (((essaiReplace.Texte) Like "*arv*"));


J'ai essayé les mêmes caractères génériques que l'on peut utiliser avec LIKE du genre

Replace([Texte], [012345678],"")

mais ca ne remplace rien

2 réponses

Messages postés
33206
Date d'inscription
mercredi 22 octobre 2003
Statut
Modérateur
Dernière intervention
3 août 2021
351
Bonjour,

- Quel SGBD utilises tu ? ( Mysql, SqlServer, Access, oracle ... ?)

- Pourrais tu nous donner la structure de ta Table ainsi qu'un dump de quelques données ?


Messages postés
11
Date d'inscription
lundi 4 octobre 2004
Statut
Membre
Dernière intervention
27 janvier 2016

Il s'agit de Microsoft Office Access 2003

Texte:
R110010102@arv#0
R110010102@arv#0
R110010102@i#1
R110010102@i#1
R110010102@i#1
R110010102@s#2
R110010102@s#2
R110011001@s#0
R110011001@s#0
...


J'utilise la variable "texte" pour créer de nouvelles variables selon certaines parties de la variable: R11 par ex. correspond à une institution, R1 à un temps, ce qui suit @ correspond à une phase etc

Voilà la requête que j'utilise pour l'instant, ca marche très bien, mais je voudrais simplifier
SELECT TableGlobale.Texte
,Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace([Texte],"R1",""),"relu",""),"R2",""),"1",""),"2",""),"0",""),"3",""),"4",""),"5",""),"6",""),"7",""),"8",""),"9",""),"@",""),"#","") AS Phase
, Replace(Replace(Replace(Replace(Replace(Replace (Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace([Texte],"R1","T"),"R2","T"),"relu","")
,"i",""),"arv",""),"s",""),"c",""),"e",""),"m",""),"T1","Bo"),"T2","Na"),"T3","St"),"T4","Li"),"3",""),"4",""),"5",""),"6",""),"7",""),"8",""),"9",""),"@",""),"#",""),"2",""),"1",""),"0","") AS Institution
,Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace([Texte],"R1","A"),"R2","B"),"3",""),"4",""),"5",""),"6",""),"7",""),"8",""),"9",""),"@",""),"#",""),"2",""),"1",""),"0",""),"relu","") ,"i",""),"arv",""),"s",""),"c",""),"e",""),"m",""), "A","T1"),"B","T2") AS Tps
,TableGlobale.numEnonce
, TableGlobale.Loc
, IIf([KOtab]=0,TableGlobale!Categorie,"NoTag") AS Categorie
, TableGlobale.KOtab, TableGlobale.KO, TableGlobale.Enonce
, IIf([KOtab]=0,TableGlobale!Grammaire,"NoTag") AS Grammaire
, IIf([KOtab]=0,TableGlobale!CatGen,"NoTag") AS CatGen
, IIf([KOtab]=0,TableGlobale!Tag,"NoTag") AS Tag
, IIf([KOtab]=0,TableGlobale!Valeur,"NoTag") AS Valeur
, TableGlobale.NPhrase
INTO TableGlobaleCorrect
FROM TableGlobale;



merci d'avance