【发布时间】:2014-06-19 06:57:46
【问题描述】:
我正在尝试解析 VML 路径值(这篇文章与 String manipulation for VML Path 不同)。 这有一个更复杂的路径值需要处理。 我有这个字符串值
m@0,l@0@0,0@0,0@2@0@2@0,21600@1,21600@1@2,21600@2,21600@0@1@0@1,250,350,450,@5,xe
我在这里有四个命令 m、l、x 和 e。以下总结了我的目标。
m@0,
l
@0 @0
0 @0
0 @2
@0 @2
@0,21600
@1,21600
@1@2
21600@2
21600@0
@1@0
@1,250
350,450
@5,
x
e
在代码中,我认为下面是一个很好的表示。
String command_type = "m" List<String, String> parameters = add("@0", "0") // because the y parameter is not specified I need to force it to 0
String command_type = "l" List<String, String> parameters = add("@0", "@0")
add("0", "@0")
add("0", "@2")
add("@0", "@2")
add("@0", "216000")
add("@1", "216000")
add("@1", "@2")
add("21600", "@2")
add("21600", "@0")
add("@1", "@0")
add("@1", "250")
add("350", "450")
add("@5", "0") //because the y parameter is not specified I need to force it to 0
String command_type = "x" (can have no parameter )
String command_type = "e" (can have no parameter )
这是我从 VML 中注意到的事情。
命令前面没有逗号 ,(适用于所有 vml 命令,除了第一个命令 m。
参数成对出现(x 和 y 对)
我看到了这个链接Java String.split() Regex,也许可以使用正则表达式来检索参数。
【问题讨论】:
标签: java string string-matching stringtokenizer vml