# String to Expression?

**URL:** <https://forum.kirupa.com/t/string-to-expression/215421>\
**Category:** Uncategorized\
**Created:** [February 7, 2007, 6:29am UTC](https://forum.kirupa.com/t/string-to-expression/215421 "2007-02-07T06:29:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![blitzman](https://avatars.discourse-cdn.com/v4/letter/b/ccd318/32.png) [@blitzman](https://forum.kirupa.com/u/blitzman)\
**Post date:** [February 7, 2007, 6:29am UTC](https://forum.kirupa.com/t/string-to-expression/215421/1 "2007-02-07T06:29:46Z")

</div>

I would like to convert a string into an equation that can be evaluated.

I’m loading in properties for items in an RPG. So say the item is a sword, one of the properties would be the equation to calculate damage. This property is loaded in as a string, ‘str/4’. Meaning the characters strength divided by 4.

so for example:

item\_damage = ‘str/4’ //this is actually loaded from the xml  
str = 12

I want to evaluate this:

damage = str/4 //should equal 3

Anyone have any ideas?
