What do you mean by "anything else"?
All the other lines? Or the uninterested parts of the line with the resolution?
You can do both:
Code: Select all
$str = "<clipboard>";
foreach($line, $str, "<crlf>"){
$match = regexreplace($line, ".+ (\d+[x|X]\d+) .+", "$1");
if ($match != $line) {msg "$line <crlf 3>$match";}
}
Result:
Code: Select all
Stream #0.0(ger): Video: h264 (High), yuv420p, 1280x528 [PAR 1:1 DAR 80:33], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
1280x528
The trick is that regexreplace() returns the original input if the regex didn't match.
If the regex didn't match, because the pattern is not found, we get the original input back as result.
If the pattern match, we get the result of the regex evaluation back.
So, if we get the original input back, we know the regex didn't have matched and we can skip this line.
If the result is not ( != ) the original input, the pattern has matched somehow.
If the pattern or the result is the right thing we want or not is an other story
To extract the resolution inside the line we use an back reference group
by putting the regex to extract the need part "
\d+[x|X]\d+" into parentheses
(\d+[x|X]\d+)
which we can access/reuse by
"$1"
The part before and after we match by the regex
".+ " and
" .+"
but without backreference group parentheses, because we only have to match them, but didn't need them in the result.
Backreference group parentheses are counted from left to right.
So f.ex. we could also smtg like
regexreplace($line, "(.+ )(\d+[x|X]\d+)( .+)", "$2");
then we would get:
$1 -> " Stream #0.0(ger): Video: h264 (High), yuv420p, "
$2 -> "1280x528"
$3 -> " [PAR 1:1 DAR 80:33], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)"
HTH?