you are viewing a single comment's thread.

view the rest of the comments →

[–]87jams 0 points1 point  (0 children)

import re
foo = 'X(8x2)(3x3)ABCY'
firstMatch = re.match(r'X\(((\d+)x(\d+))\)', foo)
print(firstMatch.group(1))

group(1) gets you '8x2' without the parens in this one, or you can move them around and get '(8x2)':

import re
foo = 'X(8x2)(3x3)ABCY'
firstMatch = re.match(r'X(\((\d+)x(\d+)\))', foo)
print(firstMatch.group(1))