Regex - Skip certain Characters to make a match


(Shaine) #1

Hi everyone

I’m having an issue with Regex.

I’m trying to make a match of T0000001 (2, 3 and so on) from imports from an MT940 file.

However, some of the lines it searches has what I can describe as positioners. These are shown as a question mark, followed by 2 digits, such as ?21 or ?22. These positioners describe a new position if the document were to be printed off the website and they can be anywhere in the file.

Example:

T123?214567
T?211234567

I need to disregard the positioner and match T1234567.

From what I can see, this is not possible. I have looked everywhere and tried numerous attempts.

All we have to work off is the linked image. The creators cant even confirm the flavour of Regex it is - they believe its Python but I’m unsure. There is no option for replacement etc.

Unfortunately none of the codes below have worked so far. I thought to test each code in live (Rather than via regex thinking may work different but unfortunately still didn’t work)

Tried and tested methods:

T((?21)?\d)+
^(T\d*)?\d{2}(\d*)$
T[0-9]{7}|T[0-9(?\d\d)]{10}
T\d*(?<=?\d{2})\d+
\b(T\d*)(?:?\d{2})?(\d+)\b
(T.?)?\d{2}(.)
(T(?:\d{7}|[@\d]{8}))\s

Not even sure if this would be an appropriate Q&A site for this kind of thing but I was recommended to try here.

Appreciate any help you can provide.

Kind regards