Extraxt data from a strin in a shown in a data table

I was creating a dashboard, when i tried creating a data table selected the field i want to add. But i only wanted the first 3 digits from that string. Could you guys help me with it on how to do it. there were some solutions available but did not work.

If I understand you correctly, you can create a runtime field to extract the specified string, then visualize that field.
Go to Stack management ==> Data Views ==> select your data view then create a runtime field

it should look like this :

if (doc['MSAN.keyword'].size() != 0) {
    String msan= doc['MSAN.keyword'].value;
    if (msan.length() >= 3) {
        return msan.substring(0, 3);
    }
}
return null;