I am trying to get a reference number inside a string which is in most cases precedented by "Ref." or something similar.
e.g.:
Explorer II Ref.16570 Box
The problem is that there are many different variations1 as this is user generated content. How could I retrieve the number with python which is precented by e.g. Ref.?
The number/string is not always the same pattern e.g. numbers. .They might be mixed with characters and dots and slashes but for a human eye there is almost always such a number in each line identifiable.
E.g.:
Ref.16570
Ref. 16570
Referenz 216570
Referenz 01 733 7653 4159-07 4 26
331.12.42.51.01.002
166.0173
AB012012/BB01
Ref. 167.021
PAM00292
14000M
L3.642.4.56.6
161.559.50
801
666
753
116400GV
Ref.: 231.10.39.21.03.002
3233
Ref: 233.32.41.21.01.002
T081.420.97.057.01
16750
... almost each line in the example provided contains a certain ID
A small amount of false positives would not be a problem.

matchorextract?Ref(?:erenz)?\. *(\d+). It shouldn't start with^. What you need is in 1st capturing group.