Problem with Perl regular expression pattern matching

I’m very new to Perl programming and am having trouble creating a regular expression for pattern matching. I want to pattern match a specific text string followed by a certain number of any combination of letters and digits.

For example, in some text, I want to search for the text "Bob: " and then let’s say the next 20 characters, which can be any combination of alphas and numerics. How would I construct that regex match?

Thanks in advance for your help!


You want to find “Bob:” and then capture the next 20 or so characters?

I mean, there’s always [0-9a-zA-Z]{20} for 20 alpha and numeric characters, but I suspect that’s not what you mean.

I think that is exactly what he means. Here is syntax that makes it easy to extract the match:

my $string = “Bob: 1234567890AbCdEfGhIj”;

my ($alpha_num_string) = $string =~ /Bob: [A-Za-z0-9]{20}/;