Home Ask Login Register

Developers Planet

Your answer is one click away!

Smita Ahinave February 2016

Spliting Formula using JQuery

I have already generated formulas and stored it in database.Now,when I want to use formulas,I select one formula from autocomplete list say for example :


now ,I want to split this formula and fetch bbc,cbc values from database and calculate answer.How can I split this formula and separate out operators and operands using jQuery?


Smita Ahinave February 2016

I am succeed in splitting formula by following way,

var expression = "((bbc*40%)/cbc)+52".replace(/[^A-Z]+/gi, "#").replace(/[\.]/g, "");

var operators = expression.split("#").filter(function(n){
    return n

for(var i = 0; i < operators.length; i++){
    console.log("Operator"+i+" :"+operators[i]);

May this helpful for someone...

Post Status

Asked in February 2016
Viewed 2,942 times
Voted 8
Answered 1 times


Leave an answer

Quote of the day: live life