Вы можете сделать что-то вроде этого: (Используя группу)
import re
string="Continuing operations Revenue 2 57,491 – 57,491 55,917 – 55,917 Cost of sales (54,092) (49) (54,141) (52,899) (116) (53,015) Gross profit/(loss) 3,399 (49) 3,350 3,018 (116) 2,902 Administrative expenses Profits/(losses) arising on property-related items (1,786) 31 153 89 (1,633) 120 (1,734) (4) (261) 114 (1,995) 110 Operating profit/(loss) 1,644 193 1,837 1,280 (263) 1,017 Share of post-tax profits/(losses) of joint ventures and associates Finance income Finance costs 13 5 5 (6) 98 (593) – – (38) (6) 98 (631) (30) 109 (630) (77) – (244) (107) 109 (874) Profit/(loss) before tax 1,143 155 1,298 729 (584) 145 Taxation 6 (286) (20) (306) (185) 98 (87) Profit/(loss) for the year from continuing operations 857 135 992 544 (486) 58 Discontinued operations Profit/(loss) for the year from discontinued operations 7 – 216 216 (37) (75) (112) Profit/(loss) for the year 857 351 1,208 507 (561) (54)"
s=re.search('Operating profit\/\(loss\) ([0-9, ()]*)',string)
answer=s.group(1)
print answer
Это напечатает вывод следующим образом:
1,644 193 1,837 1,280 (263) 1,017
Пожалуйста, проверьте код в LINK .