Retirer 2 strings connu dans un string

Résolu
Sentynel Messages postés 85 Date d'inscription jeudi 7 janvier 2010 Statut Membre Dernière intervention 13 juillet 2013 - 13 juil. 2013 à 17:19
elguevel Messages postés 718 Date d'inscription jeudi 19 décembre 2002 Statut Membre Dernière intervention 22 novembre 2016 - 17 juil. 2013 à 21:40
Bonjour,
Je possède 3 variable :
string1
string2
string3

string1 regroupe des caractère généré automatiquement, puis, string2 et string3
on connait string2 et string3

Comment faire pour retirer string2 et string3 pour avoir juste le caractère généré automatiquement dans string1

Exemple :
string1 = "Hello World !"
string2 = "World"
string3 = "!"
Resultat = "Hello"


Merci :)

5 réponses

Whismeril Messages postés 19029 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 26 avril 2024 656
13 juil. 2013 à 18:38
Bonsoir,

string1 = string1.Replace(string2,"");



Whismeril
3
Sentynel Messages postés 85 Date d'inscription jeudi 7 janvier 2010 Statut Membre Dernière intervention 13 juillet 2013
13 juil. 2013 à 17:33
J'ai d'abords pensé à :
string1 = string1.Remove(string1.Length - string2.Length - string3.Length, string2.Length + string3.Length);

Mais ca ne fonctionne pas
0
Sentynel Messages postés 85 Date d'inscription jeudi 7 janvier 2010 Statut Membre Dernière intervention 13 juillet 2013
13 juil. 2013 à 19:11
Merci whismeril :)
0
Whismeril Messages postés 19029 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 26 avril 2024 656
13 juil. 2013 à 20:25
De rien


Whismeril
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
elguevel Messages postés 718 Date d'inscription jeudi 19 décembre 2002 Statut Membre Dernière intervention 22 novembre 2016 3
17 juil. 2013 à 21:40
Pour répondre à ton problème, je dirais même : string1 = string1.Replace(string2,"").Replace(string3,"");


../\_/\..
.( o.o ). ~ ElGuevel ~
..> - <..
0
Rejoignez-nous