in reply to parsing a function
Output:#!/usr/bin/perl -w use strict; my @func = ( "b+c(t)+t^234.57*f(t)+Z", "a + b + c + t^324*f(t) + t^f(t)", "t^123456.3990*f(t) + 4", "12 + bt + t^32*f(t)", "a+b+c(t)+t^.23*f(t)+Z" ); foreach (@func) { if (/t\^(\d+\.?\d*|\.\d+)\*f\(t\)/) { print "$_\n n = $1\n\n"; } }
Note that this will only match one t^n*f(t) per function.b+c(t)+t^234.57*f(t)+Z n = 234.57 a + b + c + t^324*f(t) + t^f(t) n = 324 t^123456.3990*f(t) + 4 n = 123456.3990 12 + bt + t^32*f(t) n = 32 a+b+c(t)+t^.23*f(t)+Z n = .23
|
|---|