Franklin wrote:
> Hello:
> 
> I want to extract the digit from a line of text. For exmple, for a
> text line: TSC2101Net, how can I write a script to extract 2101 and
> print it?  

Use a regex to capture a series of digits:

  $_ = 'TSC2101Net';
  my ($num) = /(\d+)/;
  print "Found $num\n" if defined $num;

This will simply find the leftmost sequence of one or more digits in the
string.

HTH

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to