import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "Other\\spayables?_lt";
final String string = "FRONTKEN CORPORATION BERHAD \n"
+ "(Co. No. 651020-T) \n"
+ "(Incorporated in Malaysia) \n"
+ "CONDENSED CONSOLIDATED STATEMENT OF PROFIT OR LOSS AND OTHER \n"
+ "COMPREHENSIVE INCOME FOR THE FOURTH QUARTER ENDED 31 DECEMBER 2019 \n"
+ "(The figures have not been audited) \n"
+ "Individual Quarter Cumulative Quarter\n"
+ "Preceding Year Preceding Year\n"
+ "Current Year Corresponding Current Year Corresponding\n"
+ "Quarter Quarter To-date Period\n"
+ "31 Dec 2019 31 Dec 2018 31 Dec 2019 31 Dec 2018\n"
+ "RM '000 RM '000 RM '000 RM '000\n"
+ "Revenue 8 8,888 88,665 339,911 327,218\n"
+ "Operating expenses (61,106) ( 61,255) ( 228,967) ( 239,240)\n"
+ " Profit before depreciation and finance costs 2 7,782 2 7,410 110,944 8 7,978\n"
+ "Depreciation (3,760) (4,268) ( 17,818) (17,301)\n"
+ "Finance costs (140) (92) (756) (568)\n"
+ "Other operating income 608 1 ,375 3 ,891 5,428\n"
+ "Share of results of associated companies - - - 78\n"
+ "Profit before tax 2 4,490 2 4,425 9 6,261 7 5,615\n"
+ "Taxation (4,905) (4,415) ( 22,033) (18,613)\n"
+ "Profit after tax 1 9,585 2 0,010 7 4,228 5 7,002\n"
+ "Profit after tax attributable to :\n"
+ "Owners of the Company 1 8,199 1 8,683 6 9,170 5 2,257\n"
+ "Non-controlling interests 1 ,386 1 ,327 5 ,058 4 ,745\n"
+ "Profit for the period 1 9,585 2 0,010 7 4,228 5 7,002\n"
+ "Profit for the period 1 9,585 2 0,010 7 4,228 5 7,002\n"
+ "Other comprehensive expenses:\n"
+ "Actuarial gains 4 3 98 4 3 98\n"
+ "Foreign currency translation 2 ,253 7 2 2 ,262 ( 1,571)\n"
+ "Total comprehensive income for the period 2 1,842 2 0,480 7 6,494 5 5,829\n"
+ "Total comprehensive income attributable to:\n"
+ "Owners of the Company 2 0,277 1 9,172 7 1,291 5 1,317\n"
+ "Non-controlling interests 1 ,565 1 ,308 5 ,203 4 ,512\n"
+ "Total comprehensive income for the period 2 1,842 2 0,480 7 6,494 5 5,829\n"
+ "Earnings per share attributable to \n"
+ "equity holders of the company :\n"
+ "Basic (sen) 1.74 1.78 6.60 4.99\n"
+ "The condensed consolidated income statement is to be read in conjunction with the accompanying notes to the interim financial report.\n"
+ "The comparative figures are based on audited financial statements of the Company for the financial year ended 31 December 2018.";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
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