I have a legacy code, that uses regular expressions to search for certain text patterns within large texts and replace them with links. These expressions have numerous optional parameters, such as
(free.?)?(online.?)?Blackjack
To speed things up I want to do a quick check with plain old strpos and look for required part of the expression (in this case 'blackjack') before running the lengthy replacement with preg_replace. Is there a way to process an expression itself and extract only required part(s)? I think it's done by yet another regular expression, but just in case, I'm using PHP.