Question : perl substitution
Answered by : charlesalexandre-roy
# Basic syntax:
$your_string =~ s/regex pattern/text to substitute/;
# Where:
# - regex pattern is the pattern to search for in $your_string
# - text to substitute is the replacement text when the pattern is found
# - add g after the last slash (/) to replace all matches for each line
# Example usage:
my $dna_sequence = "AACTAGCGGAATTCCGACCGT";
# substitute GAATTC with lowercase
$dna_sequence =~ s/GAATTC/gaattc/;
print "$dna_sequence\n";
--> AACTAGCGgaattcCGACCGT
Source : http://korflab.ucdavis.edu/Unix_and_Perl/current.html | Last Update : Fri, 18 Mar 22