String.split() m'ennuie

String.split() m'ennuie - Java - Programmation

Marsh Posté le 10-11-2004 à 12:48:42    

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
Reply

Marsh Posté le 10-11-2004 à 12:48:42   

Reply

Marsh Posté le 10-11-2004 à 12:52:31    

qué ?
pourquoi voudrais tu un espace blanc ?

Reply

Marsh Posté le 10-11-2004 à 12:53:40    

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

Reply

Marsh Posté le 10-11-2004 à 12:53:57    

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

Reply

Marsh Posté le 10-11-2004 à 12:54:06    

bla\tbla\t\t [:dawa]

Reply

Marsh Posté le 10-11-2004 à 12:59:47    

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

Reply

Marsh Posté le 10-11-2004 à 13:01:48    

pouvait pas savoir [:spamafote]

Reply

Marsh Posté le 10-11-2004 à 13:04:56    

ah ouais :o

Reply

Marsh Posté le 10-11-2004 à 13:07:58    

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à !?

Reply

Marsh Posté le 10-11-2004 à 13:08:54    

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

Reply

Marsh Posté le 10-11-2004 à 13:08:54   

Reply

Marsh Posté le 10-11-2004 à 13:10:15    

jpeux en rajouter 40 que ça change rien hein

Reply

Marsh Posté le 10-11-2004 à 13:11:34    

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
Reply

Marsh Posté le 10-11-2004 à 13:13:51    

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
Reply

Marsh Posté le 10-11-2004 à 13:15:47    

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
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed