我在文件中有一行结构如下:
<IncludePath>..\..\somethingB\include;..\..\..\somethingA\Source;$(IncludePath)<\IncludePath>
我只是想在IncludePath&gt;之间打印所有内容。和$(IncludePath)
line.scan(/<IncludePath>(.*)$(IncludePath)/m)
print line
但是我和标签一起得到完整的一行。我想只是标签之间的字符串。我做错了什么?
答案 0 :(得分:0)
尝试:
> string = "<IncludePath>..\..\somethingB\include;..\..\..\somethingA\Source;$(IncludePath)<\IncludePath>"
> string[/<IncludePath>(.*?)\$\(IncludePath\)/m, 1]
#=> ".... omethingBinclude;...... omethingASource;"
或,mudasobwa建议你可以使用:
> string[/(?<=<IncludePath>).*?(?=\$\(IncludePath\))/m]
#=> ".... omethingBinclude;...... omethingASource;"