Reputation: 32114
I'm trying to find the proper regular expression to convert eregi($1,$2)
to preg_match("/$1/i",$2)
i need to consider if there will be functions with () in it, and they may appear more then once. can anyone please provide the proper regular expression to do so ?
thanks
Upvotes: 1
Views: 406
Reputation: 38318
Are you trying to modify your source code, since eregi
is deprecated? This regex will do the trick:
$source= <<<STR
eregi(\$1, \$2);
eregi('hello', 'world');
STR;
$source2= preg_replace("/eregi\(['\"]*([^\'\"),]+)['\"]*,\s*['\"]*([^'\"),]+)['\"]*\)/", 'preg_match("/$1/i", "$2")', $source);
var_dump($source2);
Upvotes: 1
Reputation: 59993
You don't want to use a regular expression to parse code.
You want to use a parser.
Upvotes: 1