0

There is piece of code that replaces the C/o,d/o,s/o or w/o as below :

if (temp.contains(",,"))
    {
        temp=temp.replace ("C/O,,","");
        temp=temp.replace ("S/O,,","");
        temp=temp.replace ("D/O,,","");
        temp=temp.replace ("W/O,,","");
    }

But i want to replace above by regex so that it automatically removes C or S or D or W if there is a char sequence ",," I am not able to get what regex can be used . Please help.

1

1 Answer 1

2

You mean this?

temp=temp.replaceAll("[SDWC]/O,,","");

For case-insensitive match,

temp=temp.replaceAll("(?i)[SDWC]/O,,","");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.