Suppose we need to extract row and col from a string ‘R1C2_row62_col24.png’:

import re
some_string = 'R1C2_row62_col24.png'
m = re.match(r".*row(\d+)_col(\d+).*.png", some_string)
row = int(
col = int(
assert row == 62
assert col == 24

or suppose we want to extract a string from a name ‘some_class_name_123.jpg’:

import re
some_string = 'some_class_name_123.jpg'
m = re.match(r"(.+)_\d+.jpg", some_string)
assert == 'some_class_name'

Test here

Character Action
. any character
\d only numbers (if we need decimal point user a backslash (.)
? Zero or one character
+ One or many
* Any character count

Good tutorial.