If you must use a regex, you can do it as follows:
preg_match('/^MyParam[^\r\n]*/m', $text, $matches);
var_dump($matches[0]);
Explanation:
[^\r\n]
- a character class that matches any characters other than a\r
or\n
.m
- multiline modifier, which changes the meaning of^
from "assert position at the beginning of the string" to "assert position at the beginning of each line".
Here, $matches[0]
will contain the complete matched string (which in this case, is what you want).
Output:
string(14) "MyParam "blue""