質問

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