Friday, November 30, 2012

split a String by * in java

Let say we have a String something like below.

String sample="abc*123";

We want to split this String by '*'. We can't do this directly.Because in split the * has a special meaning.

This not working,
String spl[]=sample.split("*");

Therefore, we should use something like below.

String spl[]=sample.split("\\*");

0 comments:

Post a Comment