ファイル内の式<disp-formula id="deqn(\d+)-(\d+)">
を探して、1つ以上の一致がある場合は、ファイル全体を検索して<xref ref-type="disp-formula" rid="deqnX">(X)</xref>
または<xref ref-type="disp-formula" rid="deqnX">X</xref>
ここで最後(\ D +)に第(\ D +)からX範囲及び<xref ref-type="disp-formula" rid="deqn$1-$2">(X)</xref>
又は<xref ref-type="disp-formula" rid="deqn$1-$2">X</xref>
ファイル内のデータを解析した後にリンクタグを変更する
サンプル入力にそれを置き換える:
<sec id="sec1">
<para>In addition, many of you will be glad to hear that <xref ref-type="disp-formula" rid="deqn1">(1)</xref> Visual Basic is now a fully object-oriented programming language <xref ref-type="disp-formula" rid="deqn3">(3)</xref>-<xref ref-type="disp-formula" rid="deqn5">(5)</xref>, with the inclusion of the long sought-after class inheritance, as well as other OOP features.</para>
</sec>
<para>In this chapter, you'll see how Visual Basic has evolved eq. <xref ref-type="disp-formula" rid="deqn1">1</xref> into the VB .NET language of today and get some sense of how and why VB .NET is different from previous versions of Visual Basic.</para>
<sec id="sec1a">
<para>How had I ever managed living without him?
<disp-formula id="deqn1-2">$$\phi=a+b-c^2$$</disp-formula></para>
<para>Gideon Cross. <xref ref-type="figure" rid="fig2">Figure 2</xref>, table 3.</para>
<para>This chapter surveys some of the new features of the .NET Framework <xref ref-type="disp-formula" rid="deqn2">(2)</xref>, <xref ref-type="disp-formula" rid="deqn5">(5)</xref> that most impact the VB developer. These include namespaces, the Common Language Runtime (CLR), and assemblies.</para>
<para>The third and final section, Part III, consists of the following appendixes:
<disp-formula id="deqn3-5">$$m=a+b-c$$</disp-formula>
</para>
</sec>
</sec>
<sec id="sec2">
<label>2.</label>
<disp-formula id="deqn6">$$\cal {X}=y=1$$</disp-formula>
<para>The switch…case Statement.</para>
<para>A discussion of language changes <xref ref-type="disp-formula" rid="deqn6">(6)</xref> from VB 6 to VB .NET.</para>
<para>A list of VB .NET intrinsic constants, as well as VB .NET enumerations and their members.</para>
</sec>
所望の出力:
<sec id="sec1">
<para>In addition, many of you will be glad to hear that <xref ref-type="disp-formula" rid="deqn1-2">(1)</xref> Visual Basic is now a fully object-oriented programming language <xref ref-type="disp-formula" rid="deqn3-5">(3)</xref> and <xref ref-type="disp-formula" rid="deqn3-5">(5)</xref>, with the inclusion of the long sought-after class inheritance, as well as other OOP features.</para>
</sec>
<para>In this chapter, you'll see how Visual Basic has evolved eq. <xref ref-type="disp-formula" rid="deqn1-2">1</xref> into the VB .NET language of today and get some sense of how and why VB .NET is different from previous versions of Visual Basic.</para>
<sec id="sec1a">
<para>How had I ever managed living without him?
<disp-formula id="deqn1-2">$$\phi=a+b-c^2$$</disp-formula></para>
<para>Gideon Cross. <xref ref-type="figure" rid="fig2">Figure 2</xref>, table 3.</para>
<para>This chapter surveys some of the new features of the .NET Framework <xref ref-type="disp-formula" rid="deqn1-2">(2)</xref>, <xref ref-type="disp-formula" rid="deqn3-5">(5)</xref> that most impact the VB developer. These include namespaces, the Common Language Runtime (CLR), and assemblies.</para>
<para>The third and final section, Part III, consists of the following appendixes:
<disp-formula id="deqn3-5">$$m=a+b-c$$</disp-formula>
</para>
</sec>
</sec>
<sec id="sec2">
<label>2.</label>
<disp-formula id="deqn6">$$\cal {X}=y=1$$</disp-formula>
<para>The switch…case Statement.</para>
<para>A discussion of language changes <xref ref-type="disp-formula" rid="deqn6">(6)</xref> from VB 6 to VB .NET.</para>
<para>A list of VB .NET intrinsic constants, as well as VB .NET enumerations and their members.</para>
</sec>
これは私は誰もがこの上で私を助けることができる、これまでに
Dim targetDirectory As String = TextBox1.Text
Dim txtFilesArray As String() = Directory.GetFiles(targetDirectory, "*.txt")
For Each txtFile In txtFilesArray
Dim input As String = File.ReadAllText(txtFile)
Dim disp As New Regex("<disp-formula id=""deqn(\d+)-(\d+)"">")
Dim match As Match = disp.Match(input)
If disp.Matches() Then
Dim a As Integer = match.Groups(1).Value
Dim b As Integer = match.Groups(2).Value
For Each c=a to b in input
Dim xref As New Regex("<xref[^>]+rid=""(?<id>deqn\d+-\d+)""[^>]*>(?<content>[^<]+)</xref>")
Dim result As String = xref.Replace(input, Function(xyz)
???????
End Function)
Next
File.WriteAllText(txtFile, result)
End If
Next
を試みた何ですか?
ただのコメントで解決策ではありません。質問を絞り込むことはできますか?さらに、状況に応じてパーサーが適切かもしれません。 – Jan
私は2,3週間前に同様の質問に答えました。 xmlパーサーを使用する方がはるかに簡単です。 http://stackoverflow.com/questions/38938984/how-to-use-matchevaluator-function-to-reduce-coding/38940068#38940068 – FloatingKiwi
@FloatingKiwi XML解析技術に精通していないxml解析技術を使用せずにそれを達成する。コードが少し大きくなるのであれば、私は気にしません。 –