2

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

1
  • Simply you can do this as String[] newDesc=Description1.split("'"); Commented Aug 20, 2018 at 9:26

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

Use this please

String[] newDesc=Description1.split("'");

Comments

0

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.

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.