문제

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