I have this multi-line string:
Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus
dictum, lorem et fringilla congue, velit libero sagittis eros, id
lobortis nisi risus ac mauris.
I would like to use PHP Compatible Regular Expression to “name capture” the second “paragraph” (the 3-line text after the new line).
I tried the following regular expression on regex101 and it works fine :
/n(n)+(?<namedGroup>([wd]+.*(n)?)+)/m
but when I tried it in PHP using the following code, nothing gets captured :
<?php
$text = file_get_contents("paragraphs.txt");
$regular_expression = '/n(n)+(?<namedGroup>([wd]+.*(n)?)+)/m';
preg_match($regular_expression, $text, $result);
print_r($result);
?>