in reply to Regular expression
Given the number assinged to the $number variable, you will be able to capture any of the first seven numbers, 0-9, and placed into the $grabbed element. This approach will return a result set as an array, therefore the parenthases are required.... my $number = 5038062; # In your example my ( $grabbed ) = $var =~ /([0-9]{7})/; print "$grabbed\n"; ...
Where you are being less strict (kind-of) with the numbers, and are now requesting to capture the first seven digits (\d) rather than the first seven digits, 0-9.... my $number = 5038062; # In your example my ( $grabbed ) = $var =~ /(\d{7})/; print "$grabbed\n"; ...
|
|---|