Warm tip: This article is reproduced from stackoverflow.com, please click
regex parsing

How to parse a command line with regular expressions?

发布于 2020-03-27 15:40:06

I want to split a command line like string in single string parameters. How look the regular expression for it. The problem are that the parameters can be quoted. For example like:

"param 1" param2 "param 3"

should result in:

param 1, param2, param 3

Questioner
Horcrux7
Viewed
92
Sam Meldrum 2008-10-13 18:58

I tend to use regexlib for this kind of problem. If you go to: http://regexlib.com/ and search for "command line" you'll find three results which look like they are trying to solve this or similar problems - should be a good start.

This may work: http://regexlib.com/Search.aspx?k=command+line&c=-1&m=-1&ps=20