How to split an input text into arguments

Hi dear Apache commons-cli lover,

You know certainly how to parse a list of arguments into options.

But possibly you may want to provide the same as a pure JVM method ; what about the : callWith(String theArgs) ?

Might sound impossible with a commons-cli library.
You probably have thought about splitting around whitespace tokens, but you forgot that arguments can contain whitespaces characters themselves.

Then how to achieve the parsing from a simple text ?
My solution is to build a powerful regex, using an online IDE called regex101.

An argument can be this, “that”, ‘that’, ‘or ”even” that’. Use the regex here from the hyperlink into your code to build a list of arguments from a plain text command line.

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.