ruby gsub function in java, replaceAll maybe? -


i've been trying translate this

    funcformat = funcformat.gsub(/sqrt\((.*)\)/,'math.sqrt(\1)') 

to in java

    funcformat = funcformat.replaceall("sqrt((.*))","math.sqrt($1)");  

or there way of formatting math text?, example :

2x^2sqrt(x^3/2) 2xpow2sqrt(xpow3/2)

thank you, , way i'm new in site.

you can use following expression:

funcformat = funcformat.replaceall("sqrt\\(([^)]*)\\)", "math.sqrt($1)"); 

although seems don't need regexes here. simple

funcformat = funcformat.replace("sqrt", "math.sqrt"); 

seems work situation.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -