GREP - Regex +(plus) vs. *(star) performance

grep, performance, regex

Solution

These two expressions:

rtmp.*?\b/
rtmp.+?\b/

match different things. `*` means "zero or more of the previous expression" (i.e. any number), `+` means "one or more of the previous expression". So `.*?` matches any number of any characters in non-greedy mode and `.+?` matches any positive number of any characters in non-greedy mode.

The speed difference is immaterial, use the expression that matches your intent.

Problem

Simple question, say I have two regular expressions ``` rtmp.*?\b/ rtmp.+?\b/ ``` It seems to be negligible difference if any on the tests I have done. I understand the technical difference between the two expressions. In my case either will do. As the question states I am simply asking about the performance difference, if any. One difference I noticed is that `+` requires `egrep` ``` grep 'rtmp.*?\b/' egrep 'rtmp.+?\b/' ```

Original source