0

hi all i have gone through many thread and i found the way but don't know how to fit in my string please give me regexpattern to solve this.

input: String [200,350,500]
output: String{"200","350","500"}

one of the article where i found something:

How to convert a String into an array of Strings containing one character each

2 Answers 2

3

Get the substring between the first and the last character and then split by ,:

String input = "[200,350,500]";
String[] split = input.substring(1, input.length() - 1).split(",");
Sign up to request clarification or add additional context in comments.

1 Comment

"[" bracket is also there
0
String input = "[200,350,500]";
String[] split = input.replaceAll("^.(.*).$","$1").split(",");

4 Comments

Could you also elaborate why this answer would work and what it exactly does?
It's make string array from the input string. Didn't it? replaseall - like sunstring but you shouldn't get string length and find last position of string
I know this, you know this, but it's valuable for the OP to know how it works as well.
I think this example in the context of the previous answer needed no comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.