Wednesday, 15 February 2012

javascript - Need a specific part of a user input -


It seems that I need a code that

  var in mercury = userIn .substring (userArray.lastIndexOf ("(") "+ 2, userArray.lastIndexOf (") ") + 2);   

... which returns no 3) when user chemical formula Cu (NO3) 2.

The current code (above) is not dynamic as it is also required to return no 3) If the user enters, then H (No. 3) 2 or Just say (No. 3) 2.

I take it that a rajx works best

This code should also do the following:

  Var inPar = userIn replace (/ ^. * \ ((. * \)). * $ /, '$ 1');   

I do not have much about chemical formulas I understand, so I do not know what a more dynamic approach should look. Sorry.

No comments:

Post a Comment