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

  FORUM HardWare.fr
  Programmation
  Java

  String.split() m'ennuie

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

String.split() m'ennuie

n°895094
the real m​oins moins
Posté le 10-11-2004 à 12:48:42  profilanswer
 

Bon,
 

"blah\t\tblah".split("\t" )

me renvoie

{"blah", "", "blah"}


 
Bien [:bien]
 
Maintenant,  

"blah\tblah\t".split("\t" )

me renvoie

{"blah", "blah"}


 
et ça [:nul]
 
Qu'est-ce que je peux faire pour, dans le 2e cas, récuperer

{"blah", "blah", ""}

?


Message édité par the real moins moins le 10-11-2004 à 12:49:12
mood
Publicité
Posté le 10-11-2004 à 12:48:42  profilanswer
 

n°895098
lorill
Posté le 10-11-2004 à 12:52:31  profilanswer
 

qué ?
pourquoi voudrais tu un espace blanc ?

n°895100
the real m​oins moins
Posté le 10-11-2004 à 12:53:40  profilanswer
 

parce que y'en a un apres mon dernier séparateur ?

n°895101
the real m​oins moins
Posté le 10-11-2004 à 12:53:57  profilanswer
 

(je veux pas un "espace blanc", je veux un empty string hein :heink:)

n°895102
Profil sup​primé
Posté le 10-11-2004 à 12:54:06  answer
 

bla\tbla\t\t [:dawa]

n°895110
the real m​oins moins
Posté le 10-11-2004 à 12:59:47  profilanswer
 

kékidi ?
je modifie pas mon entrée hein...

n°895114
Profil sup​primé
Posté le 10-11-2004 à 13:01:48  answer
 

pouvait pas savoir [:spamafote]

n°895116
lorill
Posté le 10-11-2004 à 13:04:56  profilanswer
 

ah ouais :o

n°895123
the real m​oins moins
Posté le 10-11-2004 à 13:07:58  profilanswer
 

mais merde:
http://java.sun.com/j2se/1.4.2/doc [...] rSequence)

Citation :


 The array returned by this method contains each substring of the input sequence that is terminated by another subsequence that matches this pattern or is terminated by the end of the input sequence.


i font chier là !?

n°895127
Profil sup​primé
Posté le 10-11-2004 à 13:08:54  answer
 

et tu peu pas le rajouter le \t? :D

mood
Publicité
Posté le 10-11-2004 à 13:08:54  profilanswer
 

n°895131
the real m​oins moins
Posté le 10-11-2004 à 13:10:15  profilanswer
 

jpeux en rajouter 40 que ça change rien hein

n°895133
pascal_
Posté le 10-11-2004 à 13:11:34  profilanswer
 

the real moins moins a écrit :


Qu'est-ce que je peux faire pour, dans le 2e cas, récuperer

{"blah", "blah", ""}

?


 
Au hasard, tu lis la doc  : http://java.sun.com/j2se/1.4.2/doc [...] ang.String, int)
 
et tu écrit "blah\tblah\t".split("\t", -2) :o  
 
(je précise que je suis pas spécialiste du Java, mais, voulant proposer la solution (qui s'avère être idiote) de tester la chaine en amont, j'ai quand même jeter un coup d'oeil sur la doc)
 
edit: saloperie d'URL


Message édité par pascal_ le 10-11-2004 à 13:12:54
n°895135
the real m​oins moins
Posté le 10-11-2004 à 13:13:51  profilanswer
 

han, :love:

Citation :


If n  is non-positive then the pattern will be applied as many times as possible and the array can have any length. If n is zero then the pattern will be applied as many times as possible, the array can have any length, and trailing empty strings will be discarded.


merde.
MERCI
(apprend juste à faire des liens sur hfr :p)


Message édité par the real moins moins le 10-11-2004 à 13:51:02
n°895138
pascal_
Posté le 10-11-2004 à 13:15:47  profilanswer
 

the real moins moins a écrit :

han, :love:

Citation :


If n  is non-positive then the pattern will be applied as many times as possible and the array can have any length.


merde.
MERCI
(apprend juste à faire des liens sur hfr :p)


 
Non, c'est Joce qui devrait apprendre à parser correctement les liens :o
 
test


Message édité par pascal_ le 10-11-2004 à 13:20:21

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Java

  String.split() m'ennuie

 

Sujets relatifs
Transformer un int en String d'une taille spécifiqueConcaténer un char à la suite d'une string
[XML] un "xmlns" m'ennuie quand je veux insérer un noeudConversion String en Pchar
Comment convertir Widestring en string[VBA] String trop long
Alimentation Variable() as string[DELPHI] string et syntaxe : comment "dire" ceci ?
String avec ASPDe l'utilisation du string (42,'*')
Plus de sujets relatifs à : String.split() m'ennuie


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