import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(?<=\\<h3\\>).+(?=\\<\\/h3\\>)";
final String string = "<h3>COVEMA</h3>\n"
+ "<h3>PALMERO</h3>\n"
+ "<h3>PLASTIFERRO</h3>\n"
+ "<h3>UOCRA</h3>\n"
+ "<h3>REPAS</h3>\n"
+ "<h3>BTU</h3>\n"
+ "<h3>PANEDILE</h3>\n"
+ "<h3>ELEPRINT</h3>\n"
+ "<h3>JOSÉ J. CHEDIACK</h3>\n"
+ "<h3>NIRO CONSTRUCCIONES</h3>\n"
+ "<h3>HELPORT</h3>\n"
+ "<h3>BISCAYNE</h3>\n"
+ "<h3>COARCO</h3>\n"
+ "<h3>ESUCO</h3>\n"
+ "<h3>CPC</h3>\n"
+ "<h3>TEL 3</h3>\n"
+ "<h3>CARTELLONE</h3>\n"
+ "<h3>MACRO</h3>\n"
+ "<h3>VIAL AGRO</h3>\n"
+ "<h3>ISOLUX CORSÁN</h3>\n"
+ "<h3>AFCP</h3>\n"
+ "<h3>FINNING</h3>\n"
+ "<h3>ROGGIO</h3>\n"
+ "<h3>ROVELLA CARRANZA</h3>\n"
+ "<h3>ACINDAR</h3>\n"
+ "<h3>IERIC</h3>\n"
+ "<h3>IGARRETA MÁQUINAS</h3>\n"
+ "<h3>RIVA</h3>\n"
+ "<h3>GRUPO ESTISOL</h3>\n"
+ "<h3>IECSA</h3>\n"
+ "<h3>ARMAFERRO</h3>\n"
+ "<h3>BRICONS</h3>\n"
+ "<h3>CNH INDUSTRIAL</h3>\n"
+ "<h3>PAOLINI</h3>\n"
+ "<h3>SERVIUR</h3>\n"
+ "<h3>SANDVIK</h3>\n"
+ "<h3>DECAVIAL</h3>\n"
+ "<h3>ODEBRECHT</h3>\n"
+ "<h3>ENAS</h3>\n"
+ "<h3>SITRA</h3>\n"
+ "<h3>SUPERCEMENTO</h3>\n"
+ "<h3>JCR</h3>\n"
+ "<h3>CONSTRUMEX</h3>\n"
+ "<h3>BRIALES</h3>\n"
+ "<h3>CAPUTO</h3>\n"
+ "<h3>LUCIANO</h3>\n"
+ "<h3>GALICIA</h3>\n"
+ "<h3>VICTOR CONTRERAS</h3>\n"
+ "<h3>SIKA ARGENTINA</h3>\n"
+ "<h3>CRIBA</h3>\n"
+ "<h3>BOETTO Y BUTTIGLIENGO</h3>\n"
+ "<h3>MILICIC</h3>\n"
+ "<h3>PERIODICO EL CONSTRUCTOR</h3>\n"
+ "<h3>PHONERENTAL</h3>\n"
+ "<h3>DOS ARROYOS</h3>\n"
+ "<h3>MARTINEZ Y DE LA FUENTE</h3>\n"
+ "<h3>AUSA</h3>\n"
+ "<h3>LUIS LOSI</h3>\n"
+ "<h3>AESA</h3>\n"
+ "<h3>CONSTRUCTORA SUDAMERICANA</h3>\n"
+ "<h3>PLANTEL</h3>\n"
+ "<h3>PCR</h3>\n"
+ "<h3>BANCO DE LA NACIÓN ARGENTINA</h3>\n"
+ "<h3>SUBTERRÁNEOS DE BUENOS AIRES</h3>\n"
+ "<h3>HOLA SIM</h3>\n"
+ "<h3>JOSÉ LUIS TRIVIÑO</h3>\n"
+ "<h3>TECHINT</h3>\n"
+ "<h3>EDUARDO COLOMBI</h3>\n"
+ "<h3>ALEMARSA</h3>\n"
+ "<h3>CENTRO CONSTRUCCIONES</h3>\n"
+ "<h3>TECNIPISOS</h3>\n"
+ "<h3>XAPOR</h3>\n"
+ "<h3>FONTANA NICASTRO</h3>\n"
+ "<h3>CONCRET-NOR</h3>\n"
+ "<h3>DYCASA</h3>\n"
+ "<h3>BURGWARDT</h3>\n"
+ "<h3>SULLAIR</h3>\n"
+ "<h3>FONDO FIDUCIARIO FEDERAL DE INFRAESTRUCTURA REGIONAL</h3>\n"
+ "<h3>FLOWTEX</h3>\n"
+ "<h3>PETERSEN THIELE Y CRUZ</h3>\n"
+ "<h3>LIHUÉ</h3>\n"
+ "<h3>IRAM</h3>\n"
+ "<h3>ESTUDIO YMAZ</h3>\n"
+ "<h3>VIDOGAR</h3>\n"
+ "<h3>BICE</h3>\n"
+ "<h3>ROMERO CAMMISA</h3>\n"
+ "<h3>BATIMAT</h3>\n"
+ "<h3>ALBA CAUCIÓN</h3>\n"
+ "<h3>PROBA</h3>\n"
+ "<h3>ICF</h3>\n"
+ "<h3>TECMA</h3>\n"
+ "<h3>ALESTE</h3>\n"
+ "<h3>DELEGACIÓN PROVINCIA DE BUENOS AIRES</h3>\n"
+ "<h3>HIDRAVIAL</h3>\n"
+ "<h3>BANCO CIUDAD</h3>\n"
+ "<h3>LAMANNA</h3>";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(string);
while (matcher.find()) {
System.out.println("Full match: " + matcher.group(0));
for (int i = 1; i <= matcher.groupCount(); i++) {
System.out.println("Group " + i + ": " + matcher.group(i));
}
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html