0

hi to all i have this code have this code which reads a some text and it extracts any strings between the '[' and ']' and it should print it on the screen

String lines[] = {addressString};
for (int i = 0; i < lines.length; i++) {
    int be = lines[i].indexOf('[');
    int e = lines[i].indexOf(']');
    String fields = lines[i].substring(be+1, e);
}

my question is that i want to change the string "fields" to an array string so when i print it i can print it as fields[0],fields[1],....etc until the end of the text....?

any suggestions...??

Thanks a lot

1 Answer 1

1

Is this what you mean?

String lines[] = {addressString};
String fields[] = new String[lines.length];
for (int i = 0; i < lines.length; i++) {
    int be = lines[i].indexOf('[');
    int e = lines[i].indexOf(']');
    fields[i] = lines[i].substring(be+1, e);
}
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.