Regular Expressions starting or ending with “.*”

It is not necessary to put .* or .*? into the beginning or end of regular expressions to match something anywhere inside the string. So for example regcomp(&regex, ".*ab+c") can be replaced with the simpler: regcomp(&regex, "ab+c"). If you wish to match and extract the prefix, you should say (.*?) or (.*).