Reputation: 493
Suppose i have a String, below
String myText="I'm a android developer and i'm developing an android app";
so i want to split the above string with(" ' "),
and want to put it on a textView so how it is possible. i have used this code
split(Pattern.quote("'"));
so my complete code is :
textUser.setText(User);
String[] newDesc=Description1.split(Pattern.quote("'"));
for(String w:newDesc){
textDesc.setText(w);
}
but this is not working. Please resolve my issue
Upvotes: 2
Views: 6447
Reputation: 10105
Use the below code to understand the split string you need:
Example : String myText = "I'm a android developer and i'm developing an android app";
String[] strParts = myText.split("'");
Then
String strFirstString = strParts[0]; // I
String strSecondString = strParts[1]; // m a android developer and i
String strThirdString = strParts[2]; // m developing an android
Now display whichever String you want, in your textView.
Upvotes: 0
Reputation: 18243
I believe Pattern.quote()
wrapps your RegExp so that it only works if the matching string in inside quotes.
In other words, I do not believe in this case it would work.
A simple String[] newDesc=Description1.split("'");
should work.
Upvotes: 2