On Sun, 24 Nov 2002, Erich C. Beyrent wrote: > Hey everyone, > > I have a web form that displays a string of data from an ASCII file, split > by the colon into seperate fields on the browser. I can then edit the > values of these fields and resend the modified data into the file. > > However, I cannot get the substitution to work correctly, I assume, because > of the metacharacters in the string. A typical original string and > replacement would be: > > $search = "../pdf/sax_quartet/BMP0016.pdf:BMP0016.pdf:No baile mas (Dance No > More):Cervantes:O'Briant:Bayside Music Press:$8.00:desc<BR>"; > $replace = "../pdf/sax_quartet/BMP0016.pdf:BMP0016.pdf:No Baile Mas (Dance > No More):Cervantes:O'Briant:Bayside:$8.00:desc<BR>"; > > Now of course, a simple > > s/$search/$replace/gi > > isn't working. Any ideas? >
Either quote the meta characters in the search string by enclosing it in \Q \E sequences or quote each meta separtately by preceeding it with a \ character, e.g. s!\Q$search\E!$replace!; or @search=split(//,$search); foreach $char (@search) { $char="\\$char" if $char=~/\W/; } $search=join('',@search); **** [EMAIL PROTECTED] <Carl Jolley> **** All opinions are my own and not necessarily those of my employer **** _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs