I can't seem to get a handle on what this expression intends to extract:
preg_match("/^(?:[\s\*]*?@([^\*\/]+?)\s(.+))/",$line,$match);
$line is a line from a text file while $match is an array
I can't seem to get a handle on what this expression intends to extract:
preg_match("/^(?:[\s\*]*?@([^\*\/]+?)\s(.+))/",$line,$match);
$line is a line from a text file while $match is an array
Here's an explanation:
^ # match the beginning of the input
(?: # start non-capture group 1
[\s*]*? # match any character from the set {'0x09'..'0x0D', '0x20', '*'} and repeat it zero or more times, reluctantly
@ # match the character '@'
( # start capture group 1
[^*/]+? # match any character from the set {'0x00'..')', '+'..'.', '0'..'ÿ'} and repeat it one or more times, reluctantly
) # end capture group 1
\s # match a whitespace character: [ \t\n\x0B\f\r]
( # start capture group 2
.+ # match any character except line breaks and repeat it one or more times
) # end capture group 2
) # end capture group 1
An example string that the regex would match is this: * * *@abc asd
Edit:
I've released a beta version of the parser that was used to generate the explanation above. It can be downloaded here: http://big-o.nl/apps/pcreparser/pcre/PCREParser.html
This will match strings of the form
** * ***@anything_that_is_not_an_asterisk_nor_a_slash anything else
$match[1]
contains "anything_that_is_not_an_asterisk_nor_a_slash"
before the first space, $match[2]
contains " anything else"
.
the @ make me think the pattern is trying to capture element of an email... as a ROT always document the regex.
Probably tries to capture lines of comment blocks like these (excluding first and last line):
/**
* @param $arg1 etc...
* @return bool etc...
*/