質問:
次のテキスト ファイルがあるとします。
blablabla
# Block 1
# Some text
## Some more text
### Even more text
### Hello
# Some text
### Again Text
# Blank lines or lines not starting with # terminate
blablabala
# Block 1
# Some text
## Some more text
### Even more text
### Hello
# Some text
### Again Text
# Blank lines or lines not starting with # terminate
blablabla
# で始まる行のすべてのブロックを正規表現で抽出することは可能ですか?
注:
ブロックは 1 つの文字列である必要があります。# で始まるすべての行を抽出するだけで簡単です。
追加の質問:
正規表現の先頭の # の数を取得することは可能ですか?