Torna indietro   Hardware Upgrade Forum > Software > Programmazione

Recensione HONOR Magic 8 Lite: lo smartphone indistruttibile e instancabile
Recensione HONOR Magic 8 Lite: lo smartphone indistruttibile e instancabile
Abbiamo provato a fondo il nuovo Magic 8 Lite di HONOR, e per farlo siamo volati fino a Marrakech , dove abbiamo testato la resistenza di questo smartphone in ogni condizione possibile ed immaginabile. Il risultato? Uno smartphone praticamente indistruttibile e con un'autonomia davvero ottima. Ma c'è molto altro da sapere su Magic 8 Lite, ve lo raccontiamo in questa recensione completa.
Sony WF-1000X M6: le cuffie in-ear di riferimento migliorano ancora
Sony WF-1000X M6: le cuffie in-ear di riferimento migliorano ancora
WF-1000X M6 è la sesta generazione di auricolare in-ear sviluppata da Sony, un prodotto che punta a coniugare facilità di utilizzo con una elevata qualità di riproduzione dei contenuti audio e una cura nella riduzione del rumore ambientale che sia da riferimento
Snowflake porta l'IA dove sono i dati, anche grazie a un accordo con OpenAI
Snowflake porta l'IA dove sono i dati, anche grazie a un accordo con OpenAI
Snowflake ha presentato diverse novità per la sua piattaforma legate all'intelligenza artificiale. Quella forse più eclatante è una collaborazione con OpenAI, ma non mancano diverse nuove funzionalità che rendono la piattaforma più flessibile e in grado di rispondere meglio alle esigenze in continuo cambiamento delle aziende
Tutti gli articoli Tutte le news

Vai al Forum
Rispondi
 
Strumenti
Old 22-07-2010, 09:37   #1
Giovanni Tavella
Member
 
Iscritto dal: Feb 2010
Messaggi: 31
[Java] Prendere numeri e "Sotto stringhe" da una stringa

Se ho una stringa String S="10 attaccanti, 11 palloni,13 difensori"

dove ogni "parola" o "numero"contenuto nella stringa è separata dal "numero o parola" successiva da diversi "spazi vuoti", ma so che la stringa è formata da un "numero" seguito da una "parola".

Esempio: String esempio="Gianni 18 marco 1 mario 2".

vorrei sapere se esiste qualche metodo per estrarre da una stringa , prima un
"numero" e poi "una parola" separati da uno spazio o più.


Spero di essere stato chiaro



cosi va bene secondo voi(?) :


LinkedList numeri=new LinkedList();

LinkedList parole=new LinkedList();

String Esempio="Gianni 18 marco 1 mario 2";

Scanner scanner = new Scanner(Esempio);

scanner.useDelimiter("cosa metto come delimitatore"); /cosa metto come delimitatore??

while(scanner.hasNext()) {

numeri.add(scanner.next());

parole.add(scanner.next());

}
__________________
-.-''

Ultima modifica di Giovanni Tavella : 22-07-2010 alle 11:36.
Giovanni Tavella è offline   Rispondi citando il messaggio o parte di esso
Old 22-07-2010, 09:45   #2
!fazz
Moderatore
 
L'Avatar di !fazz
 
Iscritto dal: Nov 2006
Messaggi: 22004
regex

Quote:
split

public String[] split(String regex,
int limit)

Splits this string around matches of the given regular expression.

The array returned by this method contains each substring of this string that is terminated by another substring that matches the given expression or is terminated by the end of the string. The substrings in the array are in the order in which they occur in this string. If the expression does not match any part of the input then the resulting array has just one element, namely this string.

The limit parameter controls the number of times the pattern is applied and therefore affects the length of the resulting array. If the limit n is greater than zero then the pattern will be applied at most n - 1 times, the array's length will be no greater than n, and the array's last entry will contain all input beyond the last matched delimiter. 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.

The string "boo:and:foo", for example, yields the following results with these parameters:

Regex Limit Result
: 2 { "boo", "and:foo" }
: 5 { "boo", "and", "foo" }
: -2 { "boo", "and", "foo" }
o 5 { "b", "", ":and:f", "", "" }
o -2 { "b", "", ":and:f", "", "" }
o 0 { "b", "", ":and:f" }

An invocation of this method of the form str.split(regex, n) yields the same result as the expression

Pattern.compile(regex).split(str, n)

Parameters:
regex - the delimiting regular expression
limit - the result threshold, as described above
Returns:
the array of strings computed by splitting this string around matches of the given regular expression
Throws:
PatternSyntaxException - if the regular expression's syntax is invalid
Since:
1.4
See Also:
Pattern

__________________
"WS" (p280,cx750m,4790k+212evo,z97pro,4x8GB ddr3 1600c11,GTX760-DC2OC,MZ-7TE500, WD20EFRX)
Desktop (three hundred,650gq,3800x+nh-u14s ,x570 arous elite,2x16GB ddr4 3200c16, rx5600xt pulse P5 1TB)+NB: Lenovo p53 i7-9750H,64GB DDR4,2x1TB SSD, T1000
!fazz è offline   Rispondi citando il messaggio o parte di esso
Old 22-07-2010, 11:17   #3
Giovanni Tavella
Member
 
Iscritto dal: Feb 2010
Messaggi: 31
I no speak English

__________________
-.-''
Giovanni Tavella è offline   Rispondi citando il messaggio o parte di esso
Old 22-07-2010, 15:11   #4
!fazz
Moderatore
 
L'Avatar di !fazz
 
Iscritto dal: Nov 2006
Messaggi: 22004
Quote:
Originariamente inviato da Giovanni Tavella Guarda i messaggi
allora meglio che lo impari, almeno quello tecnico altrimenti nella programmazione non vai tanto avanti

cmq in parole povere la classe string ha il metodo split che permette di dividere una stringa in un insieme di stringhe (restituite in un array) secondo quanto definito nella regex passata come parametro

http://java.html.it/articoli/leggi/2...olari-in-java/
__________________
"WS" (p280,cx750m,4790k+212evo,z97pro,4x8GB ddr3 1600c11,GTX760-DC2OC,MZ-7TE500, WD20EFRX)
Desktop (three hundred,650gq,3800x+nh-u14s ,x570 arous elite,2x16GB ddr4 3200c16, rx5600xt pulse P5 1TB)+NB: Lenovo p53 i7-9750H,64GB DDR4,2x1TB SSD, T1000
!fazz è offline   Rispondi citando il messaggio o parte di esso
 Rispondi


Recensione HONOR Magic 8 Lite: lo smartphone indistruttibile e instancabile Recensione HONOR Magic 8 Lite: lo smartphone ind...
Sony WF-1000X M6: le cuffie in-ear di riferimento migliorano ancora Sony WF-1000X M6: le cuffie in-ear di riferiment...
Snowflake porta l'IA dove sono i dati, anche grazie a un accordo con OpenAI Snowflake porta l'IA dove sono i dati, anche gra...
Sistema Mesh Roamii BE Pro: il Wi-Fi 7 secondo MSI Sistema Mesh Roamii BE Pro: il Wi-Fi 7 secondo M...
Recensione HUAWEI Mate X7: un foldable ottimo, ma restano i soliti problemi Recensione HUAWEI Mate X7: un foldable ottimo, m...
Google annuncia le date ufficiali di I/O...
Nuovo rilancio di Amazon Haul: -20% se s...
NVIDIA azzera la partecipazione in Arm H...
Crimson Desert può diventare GOTY...
HONOR Magic 8 Lite ufficiale: il nuovo s...
Apple prepara occhiali smart, un ciondol...
WordPress integra un assistente AI che m...
La FIA ha controllato a caldo il motore ...
Sicurezza smart a meno di 100€: arriva l...
La carta Pokémon da 16,5 milioni ...
Robot umanoidi che fanno parkour e backf...
Meta ha brevettato un'IA capace di pubbl...
Sorpasso di TCL a Samsung nel mercato gl...
Speciale monitor in offerta su Amazon: d...
AMD smentisce i ritardi di Instinct MI45...
Chromium
GPU-Z
OCCT
LibreOffice Portable
Opera One Portable
Opera One 106
CCleaner Portable
CCleaner Standard
Cpu-Z
Driver NVIDIA GeForce 546.65 WHQL
SmartFTP
Trillian
Google Chrome Portable
Google Chrome 120
VirtualBox
Tutti gli articoli Tutte le news Tutti i download

Strumenti

Regole
Non Puoi aprire nuove discussioni
Non Puoi rispondere ai messaggi
Non Puoi allegare file
Non Puoi modificare i tuoi messaggi

Il codice vB è On
Le Faccine sono On
Il codice [IMG] è On
Il codice HTML è Off
Vai al Forum


Tutti gli orari sono GMT +1. Ora sono le: 11:16.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Served by www3v