java - How to split a String of numbers and chars, only by chars -
i need split string parts of number sequences , chars between them. this:
input: "123+34/123(23*12)/100" output[]:["123","+","34","/","123","(","23","*","12",")","/","100"]
is somehow possible, or possible split string multiple chars? otherwise, possible loop through string in java?
you can utilize regular expression.
string input = "123+34/123(23*12)/100"; pattern pattern = pattern.compile("\\d+|[\\+\\-\\/\\*\\(\\)]"); matcher matcher = pattern.matcher(input); while(matcher.find()) { system.out.println(matcher.group()); }
java regex string split
No comments:
Post a Comment