Torna indietro   Hardware Upgrade Forum > Software > Programmazione

Recensione vivo X300 Pro: è ancora lui il re della fotografia mobile, peccato per la batteria
Recensione vivo X300 Pro: è ancora lui il re della fotografia mobile, peccato per la batteria
vivo X300 Pro rappresenta un'evoluzione misurata della serie fotografica del produttore cinese, con un sistema di fotocamere migliorato, chipset Dimensity 9500 di ultima generazione e l'arrivo dell'interfaccia OriginOS 6 anche sui modelli internazionali. La scelta di limitare la batteria a 5.440mAh nel mercato europeo, rispetto ai 6.510mAh disponibili altrove, fa storcere un po' il naso
Lenovo Legion Go 2: Ryzen Z2 Extreme e OLED 8,8'' per spingere gli handheld gaming PC al massimo
Lenovo Legion Go 2: Ryzen Z2 Extreme e OLED 8,8'' per spingere gli handheld gaming PC al massimo
Lenovo Legion Go 2 è la nuova handheld PC gaming con processore AMD Ryzen Z2 Extreme (8 core Zen 5/5c, GPU RDNA 3.5 16 CU) e schermo OLED 8,8" 1920x1200 144Hz. È dotata anche di controller rimovibili TrueStrike con joystick Hall effect e una batteria da 74Wh. Rispetto al dispositivo che l'ha preceduta, migliora ergonomia e prestazioni a basse risoluzioni, ma pesa 920g e costa 1.299€ nella configurazione con 32GB RAM/1TB SSD e Z2 Extreme
AWS re:Invent 2025: inizia l'era dell'AI-as-a-Service con al centro gli agenti
AWS re:Invent 2025: inizia l'era dell'AI-as-a-Service con al centro gli agenti
A re:Invent 2025, AWS mostra un’evoluzione profonda della propria strategia: l’IA diventa una piattaforma di servizi sempre più pronta all’uso, con agenti e modelli preconfigurati che accelerano lo sviluppo, mentre il cloud resta la base imprescindibile per governare dati, complessità e lock-in in uno scenario sempre più orientato all’hybrid cloud
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: 21914
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: 21914
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 vivo X300 Pro: è ancora lui il re della fotografia mobile, peccato per la batteria Recensione vivo X300 Pro: è ancora lui il...
Lenovo Legion Go 2: Ryzen Z2 Extreme e OLED 8,8'' per spingere gli handheld gaming PC al massimo Lenovo Legion Go 2: Ryzen Z2 Extreme e OLED 8,8'...
AWS re:Invent 2025: inizia l'era dell'AI-as-a-Service con al centro gli agenti AWS re:Invent 2025: inizia l'era dell'AI-as-a-Se...
Cos'è la bolla dell'IA e perché se ne parla Cos'è la bolla dell'IA e perché se...
BOOX Palma 2 Pro in prova: l'e-reader diventa a colori, e davvero tascabile BOOX Palma 2 Pro in prova: l'e-reader diventa a ...
Tutti gli sconti Apple su Amazon: tornan...
Altro che entry-level: due smartwatch Am...
Roscosmos ha posticipato (ancora) il lan...
Isar Aerospace si prepara al secondo lan...
Tory Bruno è entrato in Blue Orig...
Fujifilm lancia la cartuccia per archivi...
Dreame H15 Mix: la soluzione 7-in-1 per ...
AirPods Pro 3 in forte sconto su Amazon:...
36 offerte Amazon, molte appena partite:...
2 caricatori multipli eccezionali: da 28...
OLED e 360 Hz a un prezzo senza preceden...
Roborock Q10 S5+ a un prezzo molto conve...
Upgrade PC a prezzo ridotto: le migliori...
Sono i 6 smartphone migliori su Amazon: ...
Google Pixel 9a a 361€, mai così ...
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: 14:41.


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