Budokan_Kirsil Posted June 18, 2012 Report Share Posted June 18, 2012 Hola, Este es mi problema: Tengo esta cadena: <label name="Class-0593_70"></label> Quiero, mediante una expresión regular, recuperar Class-0593_70 Acá dejo el código de lo que he estado intentando hacer: Antes, seguramente el error está acá:Pattern patron = Pattern.compile("<label name=“(\\[a-zA-Z_0-9-]+)”></label>");try{FileReader fr = new FileReader("medical.xml");BufferedReader bf = new BufferedReader(fr);String sCadena; int auxiliar = 0;Pattern patron = Pattern.compile("<label name=“(\\[a-zA-Z_0-9-]+)”></label>");Matcher matcher; while((sCadena = bf.readLine())!=null){if(auxiliar >=2){System.out.println(sCadena);/* Aplicar expresión regular para obtener solamente el nombre de la etiqueta. */matcher = patron.matcher(sCadena);matcher.find();System.out.println(matcher.group(1));}auxiliar ++;}} Gracias por la ayuda. Saludos! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now