Split String by Spaces Outside Quotes
Given a string containing words separated by spaces, split it into tokens where spaces outside single quotes act as delimiters and spaces inside single quotes are preserved as part of the same token. Example: Input: "a b abcf' fjehwfiew. 'd xy" Output: ["a", "b", "abcf' fjehwfiew. 'd", "xy"]
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Late August, 2026
Given a string containing words separated by spaces, split it into tokens with the following rule: - Spaces **outside** single quotes `'...'` act as delimiters. - Spaces **inside** single quotes should be preserved as part of the same token. Example: ```text Input: "a b abcf' fjehwfiew. 'd xy" Output: ["a", "b", "abcf' fjehwfiew. 'd", "xy"] ```
Hello Interview Premium
Your account is free and you can post anonymously if you choose.