in reply to case insensitive matching

Your regex does what you want. Perhaps you forgot to apply it to several occurrences of <name>, using the /g modifier.

#!/usr/bin/perl -w use strict; my $name = "There is a <NaMe> in this string"; $name =~ s/\<name\>/(*)/i; print "$name\n"; $name = "There is a <name> and another <NaMe> in this string"; $name =~ s/\<name\>/(*)/i; print "$name\n"; $name = "There is a <name> and another <NaMe> in this string"; $name =~ s/\<name\>/(*)/gi; print "$name\n"; __END__ __OUTPUT__ There is a (*) in this string There is a (*) and another <NaMe> in this string There is a (*) and another (*) in this string

(I added a (*) to your regex to show where the replacement was taking place.)

Ther first time, your regex worked fine, because <NaMe> was the first and only occurrence. The second time it failed because there were two occurrences. The third time, with the /g modifier, it matched both names.