in reply to Re4: Is there an InString-like function?
in thread Is there an InString-like function?

so is /^(?:$pattern)/ faster than just /^($pattern)/

Replies are listed 'Best First'.
Re6: Is there an InString-like function?
by Hofmator (Curate) on Jul 24, 2001 at 17:19 UTC

    so is /^(?:$pattern)/ faster than just /^($pattern)/
    Yes, it is. The normal parentheses capture the match inside into the variable $1 (or $2, $3, ...) and so they have to do extra work copying the characters. Both types of parentheses do grouping.

    But my solution used first an alternation inside the regex and then second a logical or to combine the result of different regexes. The result is the same but the second method is faster.

    -- Hofmator