#!/usr/bin/perl -w use strict; my $string = 'John is following jane'; # Specific $string =~ s/[jJ]ane/##Jane##/; # To preserve j or J in replacement # $string =~ s/([jJ]ane)/##$1##/; # More generic # $string =~ s/(John is following) (\w+)/$1 \u$2/;