title: Smart parsing string java
body: <p>Is there some kind of rule engine or some smart way to do this?</p>
  
  <p>I have a string like this :</p>
  
  <pre><code>test 1-2-22
  </code></pre>
  
  <p>SO that I can get these values:</p>
  
  <pre><code>name = "test"
  part_id = 1
  brand_id = 2
  count = 22
  </code></pre>
  
  <p>I have more of these so called rules from which I know the format of string. </p>
  
  <p>I was thinking I can do this with regex, but is there a better way of doing this instead?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I see some very good answers. Maybe I should have been more clear. 
  This is not the only string type that I might have, I could have a string like this :</p>
  
  <pre><code>test 3-brand 15 – 2
  </code></pre>
  
  <p>Where after parsing it should be :</p>
  
  <pre><code>name = "test"
  part_id = 2
  brand_id = 3
  count = 15
  </code></pre>
  
  <p>So I can have different strings and I need to definy a rule/pattern for each of those. What would be good way to do this? Regex is one option for now</p>