KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Possible Duplicate: Split a String based on regex I've never been a regular expression guru, so I need your help! I have a string like this: String s = "a [b c] d [e f g]"; I want to split this string using spaces as delimiters -- but I don't want to split on spaces that appear within the [] brackets. So, from the example above, I would like this array: {"a", "[b c]", "d", "[e f g]"} Any advice on what regex could be used in conjunction with split in order to achieve this? Here's another example: "[a b] c [[d e] f g]" becomes {"[a b]", "c", "[[d e] f g]"}
Tags (comma-separated)
Save Edits
Cancel