I am trying to find a way to match a phone number such as 7195551212, but I can use only "one" 5 in the search. I know how to do it with three 5's for the match expression but using just one 5 seems to be an impossible task.

Still, I don't see why I should not try to help you if you do the rest of your homework.

Look at the regex quantifiers.

You can code something like this:

Code

do_something () if ($foo =~ /d+5{3}\d*/)

;

This will detect 3 successive 5 anywhere provided previous values are also numbers (if there are 4 fives at the beginning, this will also match). Up to you to change it to be more precise in your regular expression depending on your exact needs.

I was just saying that it would also match three fives in a row of more than three fives. In some cases, that is what you want; in others, you want exactly trhee. Depending on the case, your regex can match exactly what you want, but this isn't something I can decide for you. I chose one option, perhaps the other one is better, I do not know. But both can be done easily.