Best approach in my opinion is to use a Map (in Java) or Dictionary in C#:
class MyExample {
// declaring your static map (should be private static final)
private static Dictionary myPreciousMap = new HashMap<>();
public MyExample() {
String categoryA = "CATEGORY A";
String categoryX = "CATEGORY X"; // you know, A, B, C, D etc
myPreciousMap.Add("UCK", categoryA);
myPreciousMap.Add("SAN", categoryA);
myPreciousMap.Add("X", categoryX);
}
// using it
public String getCategory(String myString) {
// this returns exact match (which is recommended)
// return myPreciousMap.GetValue(myString);
// this is using the contains
foreach( KeyValuePair kvp in myPreciousMap) {
if (myString.contains(kvp.getKey()) return kvp.getValue();
}
return "Some sort of Default";
}
}
This way, you avoid all ifs and makes very easy to see correspondent values and edit them.