Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2738 connectés 

  FORUM HardWare.fr
  Programmation
  C#/.NET managed

  Découper une chaine [newbie]

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Découper une chaine [newbie]

n°1856392
flclsd
Posté le 28-02-2009 à 23:43:43  profilanswer
 

Bonjour à tous,
 
je débute tout juste en c#
 
je souhaite pouvoir séparer une chaine avec un séparateur que je connais.
 
ex :  
 
string  : toto VS titi
string  : Titi, roger ET toto
 
j'aimerais pouvoir isoler le premier mot ou les premiers mots, qui se trouve avant VS ou ET.
 
merci d'avance de votre aide.

mood
Publicité
Posté le 28-02-2009 à 23:43:43  profilanswer
 

n°1856396
masklinn
í dag viðrar vel til loftárása
Posté le 28-02-2009 à 23:58:33  profilanswer
 

http://lmgtfy.com/?q=C%23+string+split&l=1


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?
n°1856474
flclsd
Posté le 01-03-2009 à 14:40:07  profilanswer
 

je n'y arrive pas ! j'arrive a splitter la chaine si elle contient un caractere comme , ou | mais pas a splitter sur du texte comme ma demande (VS ou ET)
 
merci

n°1856499
the big be​n
Posté le 01-03-2009 à 16:48:38  profilanswer
 

a mon avis tu ferait mieux d'implémenter ton petit split perso!
 
Tu peux utiliser la fonction indexof avec tes séparateurs et prendre chaque fois la valeur la plus petite

Message cité 2 fois
Message édité par the big ben le 01-03-2009 à 16:49:44
n°1856500
masklinn
í dag viðrar vel til loftárása
Posté le 01-03-2009 à 16:50:03  profilanswer
 

the big ben a écrit :

a mon avis tu ferait mieux d'implémenter ton petit split perso!
 
Tu peux utiliser la fonction indexof avec tes séparateurs et prendre chaque fois la valeur la plus petite


N'importe quoi [:prozac]


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?
n°1856759
Harkonnen
Modérateur
Un modo pour les bannir tous
Posté le 02-03-2009 à 16:19:25  profilanswer
 

the big ben a écrit :

a mon avis tu ferait mieux d'implémenter ton petit split perso!

 

Tu peux utiliser la fonction indexof avec tes séparateurs et prendre chaque fois la valeur la plus petite


[:the real moins moins]

 

ouais ouais, ok lol ! et Regex.Split(), c'est fait pour les chiens ?

 
Code :
  1. string test = "titi roger ET toto";
  2. string[] words = Regex.Split(test, "ET" ); // words[0] contient la chaine située avant le "ET" et words[1] contient ce qui est situé après
  3. string[] singleWords = words[0].Split(new char[]{' '}); // on extrait chaque mot de words[0] via le séparateur espace
 

et ça va pas plus loin.

Message cité 1 fois
Message édité par Harkonnen le 02-03-2009 à 16:35:02

---------------
J'ai un string dans l'array (Paris Hilton)
n°1856763
masklinn
í dag viðrar vel til loftárása
Posté le 02-03-2009 à 16:35:17  profilanswer
 

Harkonnen a écrit :


Code :
  1. string[] words = Regex.Split(test, "ET" ); // words[0] contient la chaine située avant le "ET" et words[1] contient ce qui est situé après



HarkoG [:sadnoir]

Code :
  1. string[] words = test.Split(new string[] {"ET"}, StringSplitOptions.None);


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?
n°1856765
Harkonnen
Modérateur
Un modo pour les bannir tous
Posté le 02-03-2009 à 16:39:12  profilanswer
 

oui, aussi :D


---------------
J'ai un string dans l'array (Paris Hilton)

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C#/.NET managed

  Découper une chaine [newbie]

 

Sujets relatifs
Problème conversion chaîne en nombreDécomposition d'une chaine
[Java]Découper une String en plusieurs tableaux[javascript/html] fonction pour enlever une chaine dans code hTML
modifier une chaine de caracter tout les n caracteressupprimer une partie de chaine dans un fichier texte windows ?
PHP Travailler le code binaire d'une chaineUne question sur les suites/chaine de caracteres:)
[RESOLU] Découpage de chaine 
Plus de sujets relatifs à : Découper une chaine [newbie]


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)