-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option with split property should not split quoted strings #379
Comments
I was wondering if it would be possible to accomplish this with a more sophisticated |
The following regex can be used to split on commas that are not inside a quoted region:
Example: String val = "\"-Dspring.profiles.active=foo,bar -Dspring.mail.host=smtp.mailtrap.io\",OtherOptions=\"\"";
String regex = "(,)(?=(?:[^\"]|\"[^\"]*\")*$)";
String[] parts = val.split(regex);
for (String p : parts) {
System.out.println(p);
} Prints
The alternative is to simply gather the values and parse them seperately with a CSV parser in your program. |
I closed this too soon. |
Fixed in master. |
@MarkusKramer please be aware that the next picocli release (3.9.1) will include a change in the quoting behaviour to satisfy this use case (#594) where map options can have quoted keys with embedded '=' characters. Please let me know if you have any concerns or suggestions. |
I would like to pass a map of options into my application like:
-p AppOptions="-Dspring.profiles.active=foo,bar -Dspring.mail.host=smtp.mailtrap.io",OtherOptions=""
My class:
I expect it to output the entire value for AppOptions, instead I'm only getting
-Dspring.profiles.active=foo
I believe the correct behavior should be that the split operation is not applied on quoted strings.
The text was updated successfully, but these errors were encountered: