String[] b = a.split(":[^,]+(?:, *)?");
Or:
String[] b = Pattern.compile("[^, ]+(?=:)").matcher(a).results()
.map(r -> r.group()).toArray(String[]::new);
More Related Contents:
- Counting the occurrence of a special character, numbers and letters on a user-specified string
- Extract Substrings using regex Java [closed]
- Remove HTML tags from a String
- Java – escape string to prevent SQL injection
- Regex for splitting a string using space when not surrounded by single or double quotes
- String.replaceAll(regex) makes the same replacement twice
- Rationale for Matcher throwing IllegalStateException when no ‘matching’ method is called
- Is it possible to match nested brackets with a regex without using recursion or balancing groups?
- Escaping special characters in Java Regular Expressions
- java regular expression to extract content within square brackets
- Java regex for support Unicode?
- What is the use of Pattern.quote method?
- Java: Split string when an uppercase letter is found
- Tokenizing Error: java.util.regex.PatternSyntaxException, dangling metacharacter ‘*’
- How to Split a mathematical expression on operators as delimiters, while keeping them in the result?
- Simple Java regex matcher not working
- removing characters of a specific unicode range from a string
- Can you use zero-width matching regex in String split?
- Use Java and RegEx to convert casing in a string
- Regex that Will Match a Java Method Declaration
- RegEx in Java: how to deal with newline
- Set minimum and maximum characters in a regular expression
- Pattern to extract text between parenthesis
- Java Regex Illegal Escape Character in Character Class
- Regex search with pattern containing (?:.|\s)*? takes increasingly long time
- How can split a string which contains only delimiter?
- Regular expression to get an attribute from HTML tag
- Issue with Java Regex \b
- Java’s Scanner vs String.split() vs StringTokenizer; which should I use?
- java regex pattern unclosed character class