Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Regex pattern to find string after second occurrence

I have a string like below.

#EXTINF:-1  tvg-id=ts191  tvg- 
logo=http://188.155.56.49/jumpstart/Temp_Live/cdn/HLS/Channel/imageContent-795-j5m7axrc- 
v1/imageContent-795-j5m7axrc-m1.png   group-title=Entertainment,   DD National
#KODIPROP:inputstream.adaptive.license_type=com.widevine.alpha 
#KODIPROP:inputstream.adaptive.license_key=https://tatasky.live.ott.irdeto.com/Widevine/getlicense?_session=y249xI2vioV2INEcjlJg4u7JC
https://delta12tatasky.akamaized.net/out/i/3569776.mpd

I’m looking for regex pattern to find link which is after licence_key link. I have tried below pattern but it’s giving first link only.

(?<=#KODIPROP:inputstream.adaptive.license_key=).*

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I just want https://delta12tatasky.akamaized.net/out/i/3569776.mpd as result.

Live copy available here Regexer Link to check.

>Solution :

You may use this regex for getting next line after a given fixed pattern:

#KODIPROP:inputstream\.adaptive\.license_key=.*\r?\n\K(.+)

RegEx Demo

If \K is not available in your regex flavour then use:

#KODIPROP:inputstream\.adaptive\.license_key=.*\r?\n\K(.+)

And use capture group #1 for your link.

RegEx Details:

  • #KODIPROP:inputstream\.adaptive\.license_key=: Match this prefix text literally
  • .*\r?\n: Match any text followed by line break
  • \K: Reset match info
  • (.+): Match 1+ of any characters in capture group #1
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading