I’m trying to build a regular expression for a Grok pattern. The goal is: giving a sequence of digits, I need to assign the first eleven numbers to a named capturing group, and then digits from positions 3 to 10 to a different named capturing group, starting from the beginning. For example, if the string is:
2012345678900112255
the named groups should be:
gr1: 20123456789 (first 11)
gr2: 12345678 (3 to 10)
The expression I’ve tried is
(?<gr1>d{11})^d{2}(?<gr2>d{8})
but I think that is an incorrect use of the ^, since it doesn’t start over at the beginning of the string.
I’ve tested this in https://regexr.com/ and I’m not getting an error, but not a match either.
This is to build a custom classifier in AWS Glue, so I don’t know the language.
2