问题描述
我想在单个字符串参数中像字符串一样拆分命令行.正则表达式的外观如何.问题是可以引用参数.例如:
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"
"param 1" param2 "param 3"
应导致:
param 1,param2,param 3
param 1, param2, param 3
推荐答案
我倾向于使用regexlib来解决此类问题.如果您转到: http://regexlib.com/并搜索命令行",则会找到三个结果看起来他们正在尝试解决此问题或类似问题的方法-应该是一个好的开始.
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.
这可能有效: http://regexlib.com /Search.aspx?k=command+line&c=-1&m=-1&ps=20
这篇关于如何用正则表达式解析命令行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!