P
Pimousse
Hello,
I made a quick search on this forum but i didn't find what i wanted
(maybe i'm a bad seeker ...)
I'm currently trying to replace some "tokens" in a string.
My string looks like that :
"cos(x2)+ln(x1)+exp(x2)+3*sqrt(x3)+1/ln(x2)+3.1415+exp(ln(x5))+arccos(sin(x4))+cos(x1)"
I want to replace cos by Math.cos, ln by Math.log, arccos by Math.acos
etc etc ...So my final aim would be :
"Math.cos(x2)+Math.log(x1)+Math.exp(x2)+3*Math.sqrt(x3)+1/Math.log(x2)+3.1415+Math.exp(Math.log(x5))+Math.acos(Math.sin(x4))+Math.cos(x1)"
I tried to successivily apply a replaceAll() method on my string, with
different replacement strings.
I had a problem with cos and arccos, as with sin and arcsin or tan and
arctan ... indeed, if i make something like :
myStr = myStr.replaceAll("cos\\(","Math.cos(");
Then I have a problem because it replaces arccos( by arcMath.cos( ...
And I don't want that !
The same problem occurs if I replace first arccos then cos .... the
mistake is just different
So I decided to do it another way, using a pattern and a matcher ...
But I don't succeed in finding the good pattern !
Indeed, I'm trying to find a pattern that matches "cos(" but doesn't
match "arccos".
Can anyone help me with this problem ? Have a link ? Thanks.
@++
Pimousse
PS : I've already read
http://java.sun.com/developer/technicalArticles/releases/1.4regex/
http://java.sun.com/developer/JDCTechTips/2002/tt1008.html#1
http://java.sun.com/docs/books/tutorial/extra/regex/index.html
So pleased don't give me these links to read
I made a quick search on this forum but i didn't find what i wanted
(maybe i'm a bad seeker ...)
I'm currently trying to replace some "tokens" in a string.
My string looks like that :
"cos(x2)+ln(x1)+exp(x2)+3*sqrt(x3)+1/ln(x2)+3.1415+exp(ln(x5))+arccos(sin(x4))+cos(x1)"
I want to replace cos by Math.cos, ln by Math.log, arccos by Math.acos
etc etc ...So my final aim would be :
"Math.cos(x2)+Math.log(x1)+Math.exp(x2)+3*Math.sqrt(x3)+1/Math.log(x2)+3.1415+Math.exp(Math.log(x5))+Math.acos(Math.sin(x4))+Math.cos(x1)"
I tried to successivily apply a replaceAll() method on my string, with
different replacement strings.
I had a problem with cos and arccos, as with sin and arcsin or tan and
arctan ... indeed, if i make something like :
myStr = myStr.replaceAll("cos\\(","Math.cos(");
Then I have a problem because it replaces arccos( by arcMath.cos( ...
And I don't want that !
The same problem occurs if I replace first arccos then cos .... the
mistake is just different
So I decided to do it another way, using a pattern and a matcher ...
But I don't succeed in finding the good pattern !
Indeed, I'm trying to find a pattern that matches "cos(" but doesn't
match "arccos".
Can anyone help me with this problem ? Have a link ? Thanks.
@++
Pimousse
PS : I've already read
http://java.sun.com/developer/technicalArticles/releases/1.4regex/
http://java.sun.com/developer/JDCTechTips/2002/tt1008.html#1
http://java.sun.com/docs/books/tutorial/extra/regex/index.html
So pleased don't give me these links to read