Re: Using variables in regular expression ...

From: Date: Tue, 08 Aug 2000 15:18:33 +0000
Subject: Re: Using variables in regular expression ...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-10737@lists.php.net to get a copy of this message
Heya: Ingo Theiss wrote: > > Hi everyone, > > I want to use variables inside a regular expression. Can anybody tell me the > correct syntax or is it impossible to use variables inside a regular > expression ? > > $line= ereg_replace("*$key*", chr($value), $line); One function I have constructs the regular expression outside the ereg function, places it into a variable, then use that variable as the regular expression. So, in this instance, do something like: $Expression = "*$key*"; $line= ereg_replace("$Expression", chr($value), $line); But, the problem could be your regular expression isn't correct in the first place. If so, let the list know and we'll provide some help on that. Enjoy, --Dan -- T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y More than just answers. Solutions. (SM) http://www.analysisandsolutions.com/ 4015 7 Av #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409

« previous php.general (#10737) next »