StealthRT StealthRT - 3 months ago 26
Vb.net Question

vb.net RegEX number and letter with period format

Hey all I am trying to find a REGEX that will allow me to find these types of numbers/letters in this formats:


XX.XXX


Example: DT.3 or SV.32 or TF.1


XXXX.XXX


Example: 8920.17 or 8477.1 or 1699.22

Can anyone lend a helping hand?

Answer

First format - ([A-Z]{2}\.[0-9]{1,2})

https://regex101.com/r/iT1eG6/1

Second format - ([0-9]{4}\.[0-9]{1,2})

https://regex101.com/r/pS7bC0/2

Combined - ((?:[A-Z]{2}\.[0-9]{1,2})|(?:([0-9]{4}\.[0-9]{1,2})))

https://regex101.com/r/kN6tV0/1

Regex101 breaks up the regex and explains every part. So if you need to, customise the regex further according to your needs.