in reply to Re: Replace part of a regex match
in thread Replace part of a regex match
You might like to try something like the following:
my $re = qr/ (?: # start non-capturing group [^\|]+ # as many non-pipe characters as possible \| # followed by a pipe character ){5} # and ensure there are 5 such groups in a row ([^\|]+) # capture as many non-pipe chars as possible /x;
Using Benchmark the new regular expression here was 400% faster on my computer:
Rate oldway newway oldway 108225/s -- -81% newway 563910/s 421% --
Update: corrected URL
|
---|