3v4l.org

run code in 500+ PHP versions simultaneously
<?php $s = "/**\r\n". "* @changelog https://github.com/rectorphp/rector/blob/master/docs/rector_rules_overview.md\r\n". "*/\r\n"; $annotation = '@changelog'; var_dump(extractAnnotationFromClass($s, $annotation)); function extractAnnotationFromClass(string $docComment, string $annotation): ?string { // @see https://regex101.com/r/oYGaWU/1 $pattern = '#' . preg_quote($annotation, '#') . '\s+(?<content>.*?)$#m'; preg_match($pattern, $docComment, $matches); return $matches['content'] ?? null; }

preferences:
98.53 ms | 1440 KiB | 5 Q