I'd like to trace the execution of regular expressions to see what it does at each step so I can compare how well or how poorly various regular expressions perform using java .
How can I achieve this?
For me it would be great to know how many steps the Java engine takes, so continuing to use other engines is sub-optimal from my point of view,
If you need an example of what I am talking about, I am referring to the debug functionality of the regex101.com page.
Only the first 2 options are for Java, the rest I include because they are relevant (clarifying why they are included).
jRegexAnalyser
It generates a debug under the java engine and is free and Open Source. It's not very visually pleasing and it's even hard to understand what each of the steps represents, but it does what you're looking for. It is mainly used to see the number of total steps ("Matcher Operations", "Op" column).
Link: http://www.schwebke.com/index.php/10/18/
Execution time ( benchmark )
While measuring the number of steps is a good start, the only way to really see how efficient a regular expression is is to measure the time it takes to execute, comparing 2 or more regular expressions with different text. In this way, you can also consider the time it takes to compile.
Roughly, the code would be:
Ejemplo en ideone
regex101.com
Developed under pcre , it does not use java . It is one of the best visually accomplished tools and it helps enormously to understand what is happening at the internal engine level of a regular expression, so it is worth mentioning it. Especially since I am interested in clarifying the following:
Link: https://regex101.com
* The request for regex101 to support the Java engine has been open for some time , but there is no sign of it moving forward.
RegexBuddy
Windows 2000/XP/Vista/7/8/8.1/10 (or on Linux using Wine )
It doesn't use java , but it has its own engine that accepts structs and has options for Java regular expressions (it emulates it). By far the best desktop application for evaluating regular expressions. Unfortunately, it is not free.
Link: https://www.regexbuddy.com
With Debugexx link you can parse the steps of your regular expression. I hope it helps you, greetings!
Try this expression on the site
\b\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\b