Regex problem

2000-07-10 Thread Tu Nguyen
Hi all, Can somebody show me how to use regular expression to subtitute a string with speacial character such as [* , ?] in it ? for example $string = 'test ? test'; $input = 'Start test ? test End'; $change = 'Change'; $input =~ s/$string/$change/g; After change, I expect $input = 'Start

Re: Regex problem

2000-07-10 Thread Rodney Broom
The regex engine is seeing extra stuff in $string and thinking that you are trying to build an expression with it. To get Perl to handle $string as straight text, you need to quote it like this: $input =~ s/\Q$string\E/$change/g; Rodney Broom