Python uses the "Python" regex engine re; this implementation is very slow. I want to try and use the ECMAScript implementation of regex in my python code... is there a way to do this? Here's my regex that finds IPv4 and IPv6 addresses:
(?:(?:(?:[0-9A-Fa-f]{1,4}:){6}[0-9A-Fa-f]{1,4})|(?:[0-9A-Fa-f]{1,4}::(?:[0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(?:(?:[0-9A-Fa-f]{1,4}:){2}:(?:[0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(?:(?:[0-9A-Fa-f]{1,4}:){3}:(?:[0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(?:(?:[0-9A-Fa-f]{1,4}:){4}:(?:[0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(?:(?:[0-9A-Fa-f]{1,4}:){5}:(?:[0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(?:(?:[0-9A-Fa-f]{1,4}:){6}:(?:[0-9A-Fa-f]{1,4}:){0}[0-9A-Fa-f]{1,4})|(?:(?:[0-9A-Fa-f]{1,4}:){1,6}[0-9A-Fa-f]{1,4}::)|(?:(?:[0-9A-Fa-f]{1,4})::)|(?:::(?:[0-9A-Fa-f]{1,4}:){1,6})[0-9A-Fa-f]{1,4}|(?:::(?:[0-9A-Fa-f]{1,4})))(?!\:)|(?<!\.)(?:(?<![0-9])(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(?![0-9]))(?!\.)
It may be able to be optimized further (suggestions are welcome) but, when I put it into regex101.com with some beefy test data, it becomes quickly apparent that EMCAScript is much faster than the Python version...

Implementing the Python flavor in Python is as simple as "import re"
What are the steps to implementing the ECMAScript (JavaScript) flavor that is fast enough (505.2ms) to run my code
The Python version takes around 3 seconds to run!
I am trying to implement the ECMAScript version into python