Java – How to separate numbers and characters on a String [closed] Code Answer

I have a generic string like a Serial Number
Example: ب12345678

And I want to write a method that takes String I wrote above and display it to me in the output as the following string
ب/ begin number 12-345678

Please guide me on how to make a generic parser for this type of Serial Number


To solve the issue you have with the code you have given to me in the comments this is where I end up

public class myClass { 
    public String myMethod(){
        String newString = "";
        Customer customer= new Customer(); 
        String oldString= customer.getPerson.getSerialNumber(); 
        // oldString = "A12345678" 
        if (oldString != null && StringUtils.isEmpty(oldString)){ 
            if (oldString.length()==9){ 
                // get oldString and convert to newString = A / 12-345678
                newString = oldString.substring(0, 1) + " / " + oldString.substring(1, 3) + "-" + oldString.substring(3);

newString is now A / 12-345678

Related Posts

© No Copyrights, All Questions are retrived from public domain.
Tutorial Guruji