The distinctive Perl camel is (c) O'Reilly
Perl Workshop Home Page
Home of the Bioinformatics Perl Workshop perl workshop > courses > introduction to perl (1.0.1.8) > More String Manipulation (.7/8) > match-01 (.c1)

course 1.0.1.8

Level: beginner
1.0.1.8.7
replacement operator; global matching; context behaviour of match operator

legend

course code

cat.course.level.sessions.session

e.g. 1.0.1.8

categories

0 | introduction and orientation

1 | perl fundamentals

2 | shell and prompt tools

3 | web development

4 | CPAN Modules

5 | Ruby

levels

level: all all ( 0 )

level: beginner beginner ( 1 )

level: intermediate intermediate ( 2 )

level: advanced advanced ( 3 )

[ consider using for instead of foreach ]

lecture code viewer

downloads

Code
More String Manipulation
More String Manipulation
Martin Krzywinski
#!/home/martink/bin/perl $\ = "\n"; $string = "sheep"; if ( $string =~ /(e*p)/ ) { $matched = $1; print "$matched in $string matched"; } $string = "53 big sheep"; if ( $string =~ /(\d+) \w+ (\w+)(.*)/ ) { if(1) { if($string =~ /(\d)/) { print "$1"; } } ($number,$animal) = ($1,$2); print "saw $number $animal"; } my $a = $string =~ /\w/; print $a; $string = "0123456789"; my @matches = $string =~ /.([123]+)..([678]+).*/; print $+; print join(" ",@+); print join(" ",@-); $string = "53 big sheep"; my @x = $string =~ /[aeiou]/g; print @x; $string = "a1b2c3"; my @y = $string =~ /(.)(.)/g; print join(" ",@y);

7 | More String Manipulation | 1.0.1.8.7

1.0.1.8.7.c1 | match-01 | Martin Krzywinski | code
1.0.1.8.7.c2 | match-02 | Martin Krzywinski | code
1.0.1.8.7.c3 | match-03 | Martin Krzywinski | code
1.0.1.8.7.c4 | replace-01 | Martin Krzywinski | code
1.0.1.8.7.c5 | replace-02 | Martin Krzywinski | code
1.0.1.8.7.c6 | replace-03 | Martin Krzywinski | code
1.0.1.8.7.c7 | substr | Martin Krzywinski | code
1.0.1.8.7.c8 | tr-01 | Martin Krzywinski | code
1.0.1.8.7.a1 | More String Manipulation | Martin Krzywinski | pdf
1.0.1.8.7.p1 | More String Manipulation | Martin Krzywinski | ppt
1.0.1.8.7.s1 | More String Manipulation | Martin Krzywinski | slides