import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "^.*?([\\d.]+\\s*(x|х)\\s*[\\d.]+\\s*\\/.*ET-?\\d+).*$";
final String string = "1) София 5.5.x13/4x98 ET35\n"
+ "2) Палладика 7x16/5x139.7 D98 ET5 Алмаз черный \n"
+ "3) 35TH Anniversary 8x18/5x108 ET27 Black \n"
+ "4)Уран 6x14/4x108 ET37\n"
+ "1) NG277 5.5x13/4x100 D73.1 ET38 \n"
+ "BKF = 5.5x13/4x100 D73.1 ET38\n"
+ "2) MC7/B 7x17/5x114.3 D70.6 ET54 \n"
+ "Silver = 7x17/5x114.3 D70.6 ET54\n"
+ "3) S 7 Modify 7.5x18/5x112 D73 ET42 \n"
+ "Silver = 7.5x18/5x112 D73 ET42\n"
+ "4) MK-Course Mod.08 7.5x18/5x100 D56.1 ET55\n"
+ "5) Fever-5R 8x18/5x120 D74.1 ET15 Black Mirror\n"
+ "6) R6162 9x20/5x108 D67.1 ET40 S\n"
+ "7) 35 Anniversary 8x18/5x120 ET34 Black\n"
+ "8) Lounge 8 & 10 8x18/5x110 D75 ET38 Black\n"
+ "9) RSL 5068TL 8.5x18/5x112 D71.6 ET40 MLB\n"
+ "10 Килиманджаро-5-оригинал 6x15/5x114.3 D67.1 ET52.5\n"
+ "11) RK L31F 6x15/4x100 D54.1 ET48 S\n"
+ "12 X-113 7x17/5x115 D70.1 ET41 BK/FP\n"
+ "H-323 8x15/6x139.7 H-323 8x15/6x139.7 D110.5 ET-28 HS \n"
+ "D/P H-526 7x15/6x139.7 D110.5 ET-13 HS \n"
+ "LS182 10x15/5x139.7 D108.5 ET-40 BKF \n"
+ "Талисман-Мега 7х16/5x139.7 D95.3 ET35 \n"
+ "блэк платинум P0457 8.5 x 20/5x100 D73.1 ET35 \n"
+ "Chrome 7100 7x16/6x139.7 D112.2 ET-15 Silver";
final String subst = "\\1";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(string);
// The substituted value will be contained in the result variable
final String result = matcher.replaceAll(subst);
System.out.println("Substitution result: " + result);
}
}
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