I have the following Regex:
(\d+\s+[-]\s+.*?(?=\s+-)|\d+\s+[-].*)
Regex will use this text
"Option 01 - Random phrase - Top Menu",
"Option 02 - Another Random Phrase - Su Menu",
"Option 03 - More 01 Phrase - Menu",
"Option 04 - More Phrase -",
"Option 05 - Simple Phrase"
To stay like this
01 - Random phrase ",
02 - Another Random Phrase ",
03 - More 01 Phrase ",
04 - More Phrase ",
05 - Simple Phrase ",
The function of this Regex is to get the number with dash at the beginning, and go before the last dash. Ex:
- dfhdjfhdjf01 - text text - dkfdçsjf
When there is no trace in the end basically this happens:
- dfhdjfhdjf01 - text text dkfdçsjf
However, debugging this regex on regex101.com accuses you of having 63 to 122 steps. That is, this regex is very slow.
Before criticizing the question, I have read all the documentation of the regex, I want you to know that I am referring to specific terms .. A problem that needs to be solved. After all, is not the site for this?
Tell me, how am I going to solve the slowness of this regex?