Skip to content

Instantly share code, notes, and snippets.

@chips5k
Last active August 5, 2016 22:23
Show Gist options
  • Save chips5k/57c4967ea62547722ea1f131a7de92e4 to your computer and use it in GitHub Desktop.
Save chips5k/57c4967ea62547722ea1f131a7de92e4 to your computer and use it in GitHub Desktop.
//quick regex for tokenizing math expressions - not fully tested!
((?:[^0-9+\-]?\-)?[0-9]+(?:\.[0-9]+)?|[-+\/*\^\(\)\=]{1}|(?:sin|tan|cos)(?=\()|[a-z])
//So far correctly tokenizes the following:
//15.5+-12.545bc(15+5)-(6+12)/sin(1243-12.55)=12x55--34+(cos(45.2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment