View Full Version : Regex for basic Calculator

07-23-2010, 12:39 PM
I'm making a basic calculator in Javascript (for the Windows 7 sidebar) and I'm trying to detect whether an expression can be evaluated (using eval()). I've managed to get basic function, but I'd like to add in brackets. The Regex I have so far is: /^(\d+[*-+/])*\d+$/

But I can't work out how to allow brackets, but only in the places where brackets should be (ie 4+(3*4) ok, 34+(*90) not ok, and make sure brackets are closed). Any help at all would be appreciated.