I’m (finally) starting to learn regex, and I’m wondering if there’s any notable difference between these two pattern strings. I’m trying to match lines such as “Title=Blah“, and match “Title” and “Blah” in two groups.
The problem comes with titles like “Title=The = operator“. Here are the two choices to solve the problem:
^([^=]+)=(.+)$
^(.+?)=(.+)$
Is there any difference between the two, either performance-wise or functionality-wise?
The first one requires that there be at least one non-= character before an = in order to match, whereas the second doesn’t; it’ll match on a leading ==.
Depending on your content, the first one could run significantly faster. Here’s why: