Using variables containing matched subpatterns. : Pattern matching « Regular Expression « Perl
- Perl
- Regular Expression
- Pattern matching
Using variables containing matched subpatterns.
#!/usr/local/bin/perl
while (<>) {
while (/(-?\d+)\.(\d+)([eE][+-]?\d+)?/g) {
print ("integer part $1, decimal part $2");
if ($3 ne "") {
print (", exponent $3");
}
print ("\n");
}
}
Related examples in the same category