Hey guys,
Got a script I'm working and performance and speed are the name of the game. I have optimized a large portion of the code but this chunk stands out as something to fixed or done in a more correct way.
# Don't expand metacharacters $dir =~ s/\[/\\\[/g; $dir =~ s/\]/\\\]/g; $dir =~ s/\{/\\\}/g; $dir =~ s/\~/\\\~/g; $dir =~ s/\*/\\\*/g; $dir =~ s/\?/\\\?/g;
I feel like there's got to be a better way to handle this and that the better way would be faster. That snippet will be called hundreds of thousands of times and I'm looking to squeeze out as much performance as I can.
Any tips or advice would be excellent.
--Shields
In reply to Faster way to regex this by jar00n
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |