I try to extract the media description of a SDP package.

I have a line like

a=rtpmap:113 H264/90000

(after that there is always a carriage return)

I want everything after a=rtpmap:[number][whitespace] till the carriage return, without the return itself and constructed the following Regex, which doesn't work:

(?<=(a=rtpmap:[0-9]+\s)).*(?=\r)

If I do like

(?<=(a=rtpmap:[0-9]{3}\s)).*

I get at least a result, but the number after rtpmap isn't always 3 characters long. Why isn't the + working here?

有帮助吗?

解决方案

Many regex engines do not support arbitrary- or variable-length lookbehind. .NET does but it's nearly alone in that regard.

In your case you should be better off using something like the following:

a=rtpmap:\d+ ([^\r]+)

and using the first capturing group.

其他提示

Use this instead

(?<=(a=rtpmap:(\d+)\s)).*

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top