My favorites | Sign in
Project Home Downloads Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import java.util.regex.*;

public class Main04 {
public static void main(String[] args) {
String cadena = "Matias Emiliano Alvarez Duran";

Pattern p = Pattern.compile("[A-Z]\\w+");
Matcher m = p.matcher(cadena);

while(m.find())
System.out.println("Correspondencia: " + m.group() + " - Comienza: " + m.start() + " - Termina: " + m.end());
}
}
/*
SALIDA:
Correspondencia: Matias - Comienza: 0 - Termina: 6
Correspondencia: Emiliano - Comienza: 7 - Termina: 15
Correspondencia: Alvarez - Comienza: 16 - Termina: 23
Correspondencia: Duran - Comienza: 24 - Termina: 29
*/

Change log

r17 by matiasalvarez87 on Aug 10, 2009   Diff
20090806 - #15 - libros - TIJ4 -
Ejercicios Capítulos 13 y 14
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 603 bytes, 20 lines
Powered by Google Project Hosting