On Oct 28, Bowen, Bruce said:
I see where you can test for a match in a string of data using the If ( )
statement, but can you use it with an 'index' statement?
The index() function is for finding a string in another string. Patterns
(regexes) are not allowed.
$DD = "5000|SIHHTEXT"
I've tried $d = index($DD, m/[^\d]/);
$d = index($DD, /[^\d]/);
$d = index($DD, [^\d]);
You want the location of the first non-digit?
my $non_digit = ($DD =~ /\D/) ? $-[0] : -1; # -1 means not found
(See 'perlvar' for an explanation of $-[0], in the @- array.)
will be or if there will be any cents. I need to extract the dollar / cents
out from the text. Any suggestions as to how that can be done?
That's much simpler:
my ($money) = $DD =~ /^(\d+\.?\d*)/;
That will match the numbers at the beginning of the string, optionally
allowing for a decimal point (\.) and digits after it.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://www.perlmonks.org/ % have long ago been overpaid?
http://princeton.pm.org/ % -- Meister Eckhart
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>