C# string 查找一串字段在字符串中的位置 返回
程序员文章站
2022-05-29 13:53:05
...
C# string 查找一串字段在字符串中的位置 返回
var split=" <g inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1" transform="translate(0,-277)">
<ellipse style="opacity:1;fill:#ff0000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.59999996;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers stroke fill" id="path815-5" cx="9.9379234" cy="286.9158" rx="7.7212577" ry="7.572597" />
<ellipse style="opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#ff0000;stroke-width:0.2;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers stroke fill" id="path884" cx="10.005904" cy="287.01077" rx="9.8054514" ry="9.822154" />
</g>";
var str="opacity:1;fill:#";
int cp = split.IndexOf(str);
var b= split.Substring(cp+16,6);//截取后面几个
var a =cp.ToString();//返回第一个字符的坐标
下一篇: java 使用正则获取一串字符串中的数字