我想尝试从以下地址转换SVG到地理转换器:
http://www.stoimen.com/blog/2011/02/11/from-svg-to-geo-coordinates-a-complete-guide/
问题是我没有使用PHP正则表达式:
preg_match('/(-?\d{1,2}\.?\d{0,3}),?(-?\d{1,2}\.?\d{0,3}),?(-?\d{1,2}\.?\d{0,3}),?(-?\d{1,2}\.?\d{0,3}),?(-?\d{1,2}\.?\d{0,3}),?(-?\d{1,2}\.?\d{0,3}),?/', $s, $m);
我想将其转换为C#,如:
public void Convert(string path)
{
if (path == null)
path = defaultpath.Replace("\r\n","");
var matches = path.Split('c');
var pattern= @"/(-?\d{1,2}\.?\d{0,3}),?(-?\d{1,2}\.?\d{0,3}),?(-?\d{1,2}\.?\d{0,3}),?(-?\d{1,2}\.?\d{0,3}),?(-?\d{1,2}\.?\d{0,3}),?(-?\d{1,2}\.?\d{0,3}),?/";
Regex r = new Regex(pattern, RegexOptions.IgnoreCase);
foreach (var match in matches)
{
var result = r.Match(match); //always empty
}
//...
}
但不知道我必须在模式中修改哪些才能使其正常工作?
谢谢,我将尽快发布一些来自Inkscape的转换示例,我可以使用此代码段。
更新 删除斜杠后,结果总是为空,这是匹配数组的一部分:
“ - 0.86-0.27-3.816,0.199-4.002-1.055” “-0.049-0.328-1.109-1.799-1.512-1.824” “-0.647-0.04-5.182,1.896-5.219,2.013” “-0.051,0.161,0.928,0.627,0.319,0.832” “-0.028-0.003-0.716-0.36-0.816-0.334” “-0.13,0.034-0.262,0.834-0.363,0.771” “-0.176-0.24-0.179-0.48-0.007-0.719” “-0.986-0.764-0.345,0.764-0.526,0.764” “-0.771,0,0.184-0.849-0.675,0.037” “-2.13-0.433-2.267-0.756-4.129-2.754” “-1.329-1.42,0.383-8.158-1.571-8.535” “-2.223-3.153-6.413-3.037-8.806-5.037”