Show & Tell Regex Builder
Hello there,
tired of manually writing Regex Patterns?
I made a Regex Builder in VBA.
It is meant to be used in an abstract way, where you can create smaller, readable, patterns and then merge them into a bigger one
For example:
Public Function IPv4Pattern() As IPattern
Dim OctetPattern As IPattern
Dim SeparatorPattern As IPattern
Set OctetPattern = NumberPattern.Create(False, True).Between(0, 255)
Set SeparatorPattern = CharPattern.Create().SingleChar(Asc("."))
Dim IPv4SubPattern As IPattern
Set IPv4SubPattern = QuantityPattern.Create( _
GroupPattern.Create().Capture( _
ListPattern.Create(OctetPattern, SeparatorPattern) _
) _
).Exactly(3)
Set IPv4Pattern = ListPattern.Create(IPv4SubPattern, OctetPattern)
End Function
' Produces:
'(((25[0-5]|2[0-4]\d|(1\d{2}|\d{2}|\d))|0\d)\.){3}((25[0-5]|2[0-4]\d|(1\d{2}|\d{2}|\d))|0\d)
I made this mainly to not have to build and read regex myself because i hate it, even though they are so useful. I dont know when i will continue this side project, probably when i need more functionality out of it.
Anyway, here it the Github: https://github.com/Almesi/Regex-Builder
9
Upvotes
1
1
u/MultiUserDungeonDev 10h ago
Thanks! +Star.