# Checking an input string

**URL:** https://forum.kirupa.com/t/checking-an-input-string/288408
**Category:** flash
**Created:** [May 15, 2009, 11:42am UTC](https://forum.kirupa.com/t/checking-an-input-string/288408 "2009-05-15T11:42:56Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![alva](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/alva/32/7449_2.png) [@alva](https://forum.kirupa.com/u/alva)
#### Post date: [May 15, 2009, 11:42am UTC](https://forum.kirupa.com/t/checking-an-input-string/288408/1 "2009-05-15T11:42:56Z")

</div>

I do math applications for the web. Often I have to check if a user input is correct. For example: the right answer is 3x+5. Is the user input that.

I do this by checking character by character. I don’t think that it is the best way, especially since the user may have written 5+3x, which is right, too, although it is preferred to write the other way around.

I sometimes have to check more complicated expressions, like -3x^2+7x-15 or -2 sin (4x^2).

Right now I’m doing an equation solving exercise. There I have to check what the user wants to do to the equation, like +2x or /(-5).

Does anybody have better ideas than character by character?
