11.16. Capturing

Bounus: for every word print the first vowel

if ($line =~ /([aeiou])/) {
    print $1;
}

Bonus: has a double character (e.g. 'oo')

Input:   "my loop"
/.o/
/(.)o/
if ($line =~ /(.)\1/) {
    print $1;
}
/(.+).*\1/        # lines with anything more than once
/((.+).*\1)+/     # Syntax error ! Why ?

if ($line =~ /(.*)=(.*)/) {
    print "left:  $1\n";
    print "right: $2\n";
}

If you are interested in on-site trainings by the author, please contact me directly.

Online courses:

Would you like to get
updated when I publish
the next article?

Follow me:

Google Plus Twitter RSS feed