I'm Trying to match one of the following 2 examples:
Example input 1:
<a href="Substance/acide_flavodique-4454.htm">acide flavodique</a>
Example input 2:
<a href="Medicament/ciprofloxacine_arrow_750_mg_cp_pellic-71371.htm">CIPROFLOXACINE ARROW 750 mg cp pellic</a>
and what i need to print in my file is : 1- acide flavodique :if it matches the first example. 2- ciprofloxacine :if it matches the 2nd example. Is there any problem with my regular expression or something else ? Thanks in advance!
BufferedReader lire = new BufferedReader(new FileReader(file1));
do{
String line = lire.readLine();
if(line == null)
{
break;
}
Pattern p = Pattern.compile ("<a href=\"Substance/.+>(.+)</a>|<a href=\"Medicament/.+>(.+)\\s+.+</a>");
Matcher m = p.matcher(line); System.out.println("match:"+m.group(1)+"\n");
if (m.matches()) {
writer.write(line);
writer.write(System.getProperty("line.separator"));
}
}while(true);
// }
writer.close();
}}}