I am currently looking at my old projects and trying to cleanup the code a little.
I came across a script which matches words in a huge text file if it has a specific prefix (item_name_) or suffix (_item_name).
It matches words like:
item_name_foo > foo
bar_item_name > bar
Looking at the regex itself made me think this could be improved because of the redundant \w+
between the lookarounds.
(?<=item_name_)\w+|\w+(?=_item_name)
So playing around i came up with this:
(?<=item_name_)\w+(?=_item_name)
This does not match anymore. Can my old regex even be improved?