A bit more concise:
String in = "Item(s): [item1.test],[item2.qa],[item3.production]";
Pattern p = Pattern.compile("\\[(.*?)\\]");
Matcher m = p.matcher(in);
while(m.find()) {
System.out.println(m.group(1));
}
More Related Contents:
- What do the characters ((?:(?:(?: mean in pattern-matching? [duplicate]
- Java: splitting a comma-separated string but ignoring commas in quotes
- Split string with dot as delimiter
- Use String.split() with multiple delimiters
- Java how to replace 2 or more spaces with single space in string and delete leading and trailing spaces
- Java Regex Capturing Groups
- SCJP6 regex issue
- Compare one String with multiple values in one expression
- Replace the last part of a string
- Java equivalent to PHP’s preg_replace_callback
- java.lang.StackOverflowError while using a RegEx to Parse big strings
- Split regex to extract Strings of contiguous characters
- Java regex – overlapping matches
- Generic support for ISO 8601 format in Java 6
- Find everything between two XML tags with RegEx
- Parsing CSV input with a RegEx in java
- simple java regex throwing illegalstateexception [duplicate]
- Range of valid character for a base 64 encoding
- Regex: ?: notation (Question mark and colon notation) [duplicate]
- Regex for checking if a string is strictly alphanumeric
- Java Regex pattern that matches in any online tester but doesn’t in Eclipse
- Java Pattern Matcher: create new or reset?
- Regular Expression for matching parentheses
- Java Regex – Using String’s replaceAll method to replace newlines
- Replace a String between two Strings
- Does Pattern.compile cache?
- Regex to remove spaces between numbers only
- Regex Pattern Catastrophic backtracking
- Print regex matches in java
- regex replace all ignore case