 |
|  |
 |
|
Mercator
|
 |
Sorekara no Nanimo
Jan 1970 time: 06:22
|
|
That doesn't even remotely cover it, pchang, I'm afraid... See the last use of the ^ in the one Ramo provided, for instance. It's got complex nested expressions. The one you suggested wouldn't even work with "tan(b)^4".
And, um, the one you suggested doesn't work. It should be:
s/(\w+)\^(\w+)/pow($1,$2)/g;
This one works a bit better, it'll also take functions (e.g. "tan(b)") or parenthesized expressions, but it won't work with nested parentheses:
s/(\w+(?:\([^()]*\))?)\^(\w*(?:\(.*?\))?)/pow($1,$2)/g;
That reduces the number of ^ from 794 to 4 in the one in your first post though, so you can reasonably finish it off manually.
|
|
|  |
 |
|
I Am Jeff
|
|
New Jersey
Feb 2002 time: 00:22
|
|
Why don't you just write a C program to do what you need, to replace a^b with pow(a,b) should be too hard of a program to make.
|
|
|  |
 |
|
BlackCat
|
|
Forget about doing that automaticlly - it's a waste of time. Also drop using MS tools - they sucks - use vi (no, this is not std MS bashing - I work on both unix and MS platforms, and vi is the winner).
Repeat search for ^ and make global subsititute for what you find one by one. It may sound tedious, but is much more effective than trying to figure out a way to solve it in one step. It isn't as bad as it may sound - there are of repeated statements that will be fixed by one statement.
|
|
|  |
 |
|
BlackCat
|
|
If you have multiple files, then try using cscope to make changes in those files involved. It's quite effective - I once turned a pascal program into c with this tool.
|
|
|  |
All times are GMT. The time now is 05:22. Apolyton Time is 00:22. |
top of page
|
|
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
|