|
Hi,
I need to format some experssions calculating power.
a^b to be replaced with pow(a,b)
This is the perl script that I wrote, but is does not work.
Could anyone help me in correcting the error?
#!/usr/bin/perl -w
$_ = "0.02+2*v6^2+3*v7^3;";
s/\b*(a-z0-9)+^(0-9)\b/pow($1,$2)/g;
print $_;
Expected result: 0.02+2*pow(v6,2)+3*pow(v7,3);
Error Displayed:
\b* matches null string many times in regex; marked by <-- HERE in m/\b* <-- HERE (a-z0-9)+^(0-9)\b/ at srch_rplc_pow.pl line 5.
0.02+2*v6^2+3*v7^3;
Regards,
Alm UC
|
|
|
i think you can skip the star after \b because \b represents work boundaries and logically there should never be many word boundaries in a row.
and also the ^ character may be better to type [\^]
im not sure if the \b at end should even be there at all.
I dont have a solution to the problem though.
|
|
|
Hi,
Thanks for your reply.
I was able to figure out the perl script. For anyone who might be interested it is:
s/(\w+)\^(\d+)/pow($1,$2)/g;
some text ... a^b
converted to :
some text ... pow(a,b)
-AlmUC
|
|
|
Nice post about with pow. I like your blog very much because it has very interesting articles of different topics like oracle certification dumps, brain dump and dumps for ccna and their tips and tricks. I am a very big googler and search on different topics. Between searching i found your nice blog. Thanks for your this great blog.
|
|
|
|
|
|
|
|