Branching if statements

so. i have some data in a database that needs to be assigned data based on an id.
I have a database full of items, and each item has attributes. lets say they are tools. the id could be HAMMERSTEEL.10 or HAMMERIRON12.12. the first one means it's a 10" long steel hammer with a standard head size and the second one is a 12" long iron hammer with a 12mm head or something of that nature. i have at least four different base types HAMMER AXE SCREWDRIVER. I need to assign attributes in a new table based on the item id's. what i already have is a database filled with what i want the data to look like. i'll read in hte item id HAMMERSTEEL.10 and then i'll asign the attributes in another table.

for example:

if(itemId.matches `hammerregex`) {
//  build an update statement in sql that will assign the appropriate values
}

if(itemId.matches `axeregex) {
  //build an update statemet in sql that will assign appropriate axe values
}


I want to cut down on the amount of branching if statements. any suggestions?
Was this page helpful?