Dear all,

I'm trying to extract a DNA sequence out of a larger string, i.e. the string is of the following structure:

$string = "/NOTNEEDED/*ACGACGGGTTCAAGGCAG*/NOTNEEDED/"

But when I do

$string =~ /[ACGT]/;

it matches only the last letter, i.e. "G". Why doesn't it start at the beginning?

But it gets even better, I figured that adding the greedy * should help:

$string =~ /[ACGT]*/;

and now it doesn't match anything. Shouldn't it try to match as many times as possible?

My confusion was complete when I tried

$string =~ /[ACGT]{5}/;

now it matches 5 letters, but this time from the beginning, i.e.: ACGAC.


I fail to understand that behaviour. I checked the Perl documentation a bit and I sort of understand why /[ACGT]/ only matches one letter only (but not why it starts at the end). However, I'm simply puzzled at the other things.

Thank you for your help!

Florian

Reply via email to