const regex = new RegExp('(^[A-Z]).*\\n[A-Za-z 1-9]*\\s(\\d)*\\s', 'gm')
const str = `Frontken Corporation Berhad (651020-T) 85
ANNUAL REPORT 2018
Notes To The Financial Statements
(cont’d)
9. EARNINGS PER SHARE
Basic earnings per share is calculated by dividing profit after taxation attributable to owners of the Company by the weighted
average number of ordinary shares in issue during the financial year.
The Group
2018 2017
Profit after taxation attributable to owners of the Company (RM) 52,256,898 29,857,681
Number of shares in issue as of 1 January 1,053,435,130 1,053,435,130
Effects of:
Treasury shares acquired (5,466,600) (5,466,600 )
Weighted average number of ordinary shares for basic earnings
per share computation as of 31 December 1,047,968,530 1,047,968,530
Basic earnings per ordinary share attributable
to equity holders of the Company (sen) 4.99 2.85
The Group has not issued any dilutive potential ordinary shares and hence, the diluted earnings per share is equal to the basic
earnings per share.
`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions