特定のパターンに基づいて特定の文字列を抽出する必要がある長いテンプレートがあります。いくつかの例を見てみると、そのような状況では数量詞の使用が適切であることがわかりました。たとえば、以下は私のテンプレートであり、そこから抽出する必要がwhile
ありdoWhile
ます。
This is a sample document.
$while($variable)This text can be repeated many times until do while is called.$endWhile.
Some sample text follows this.
$while($variable2)This text can be repeated many times until do while is called.$endWhile.
Some sample text.
$while($variable)
から始めて、テキスト全体を抽出する必要があります$endWhile
。次に、$variableの値を処理する必要があります。その後、元のテキストの間にテキストを挿入する必要があり$while
ます$endWhile
。変数を抽出するロジックがあります。しかし、ここで数量詞またはパターンマッチを使用する方法がわかりません。誰かが私にこれのサンプルコードを提供してもらえますか?どんな助けでも大歓迎です