나는 후속 조치로 this question으로 돌아왔다. 의 내가 텍스트를괄호 텍스트 캡쳐 (Perl RegEx)
====Example 1====
Some text that I want to get that
may include line breaks
or special [email protected]#$%^&*() characters
====Example 2====
Some more text that I don't want to get.
가 있다고 가정하고 시도하고 네 개의 등호를 "==== 예 1 ===="에서 모든 것을 얻을 수 $output = ($text =~ ====Example 1====\s*(.*?)\s*====);
를 사용하자 바로 "예 2"전에.
내가 본 on this site, regexpal.com에 기반하여 Perl은 텍스트를 찾아서 일치 시키지만 $ 출력은 null이거나 "1"로 할당됩니다. 캡쳐 괄호로 뭔가 잘못하고 있다고 확신하지만, 무엇을 알아 내지 못합니다. 어떤 도움을 주시면 감사하겠습니다. 내 전체 코드는 다음과 같습니다 괄호
$text = "====Example 1====\n
Some text that I want to get this text\n
may include line breaks\n
or special [email protected]#$%^&*() characters\n
\n
====Example 2====]\n
Some more filler text that I don't want to get.";
my ($output) = $text =~ /====Example 1====\s*(.*?)\s*====/;
die "un-defined" unless defined $output;
print $output;
내 ($ 출력) = $ text = ~/==== 예제 1 ==== \ s * (. *?) \ s * ==== /; –