Regex performance Given a string like `field1="x" ...
# random
d
Regex performance Given a string like
field1="x" field2="y" field3="z"
, how can a single regex that matches the 3 field be almost 2x slower than a
indexOf( paramName ) - substring( index ) - split( '"' ) [1]
? Do you use regex for this purpose? I'm just exploring them for the first time.
m
Regular expressions are extremely powerful with plenty of complex functionality. Unfortunately that also makes their implementation really difficult, complex and thus it's hard to get the best performance out of it.
d
Thanks for the explanation, but does that mean I used it wrong or just it couldn't be better than the "verbose" method?
h
What's the regular expression you used? Maybe that could be optimized.
d
tvg-id="([^\\"]*)".*group-title="([^\\"]*)".*tvg-logo="([^\\"]*)",(.*)
They're 4 params for iptv playlist
m
Replace the first two
.*
with
.*?
d
Thanks, I'll try tomorrow and keep you up to date