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.
asked Nov 30, 2015 at 11:44
jayendra bhatt
1,3952 gold badges22 silver badges44 bronze badges
-
Possible duplicate of Regex for C/O in address line2787184– 27871842015年11月30日 11:50:06 +00:00Commented Nov 30, 2015 at 11:50
1 Answer 1
You mean this?
temp=temp.replaceAll("[SDWC]/O,,","");
For case-insensitive match,
temp=temp.replaceAll("(?i)[SDWC]/O,,","");
answered Nov 30, 2015 at 11:47
Avinash Raj
175k32 gold badges247 silver badges289 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-java