Regular expression invalid syntax

I am trying to find index of matching using regx in python in ‘words’ list
using following code

words = matches.split(":")
index = [i for i, e in enumerate(words) if( ^(0?[1-9]|[12][0-9]|3[01])/-[/-]\d{4}$, e,re.I))]

it is returning invalid syntex.

Can anyone help in fix this? Thankyou in advance.

Hugo uses Go’s RegEx package see the Docs

A nice site to test regex is Select ‘golang’ there in the left menu for the regex that Hugo uses.

There’s also a code generator there and Python support, so you might be able to transform your Python code there to Hugo’s format with a bit more ease. Good luck!

Why you no regexr? :kissing_smiling_eyes:

1 Like