Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi there, I want to use regex to parse a m3u list. Let's suppose we have this m3u item:
#EXTINF:-1, tvg-name="THE NAME" tvg-logo="THE LOGO" group-title="THE TITLE",THE ITEM
https://www.SampleSite.com


I want to extract THE NAME,THE LOGO, THE TITLE, THE ITEM, and the URL line.

What I have tried:

I've used this pattern and it can extract all parts except "THE ITEM" that follows after a comma(,)
C#
string pattern = @"\btvg-name=""([^""]+)"".tvg-logo=""([^""]+)"".group-title=""([^""]+)"".*(,?\w).\n*(https?\S+)"
Posted
Updated 5-Oct-22 8:21am
v2

Try this:
C#
\btvg-name="([^"]+)".tvg-logo="([^"]+)".group-title="([^"]+)",(.*?)\n*(https?\S+)


If you are going to work with regexes, get a copy of Expresso[^] - it's free, and it examines and generates Regular expressions.
 
Share this answer
 
Comments
Jake-J 5-Oct-22 13:39pm    
Thanks! That works. And about Expresso[^], I've downloaded it but I can't exactly figure out how to use it.
OriginalGriff 5-Oct-22 14:05pm    
See the "Help" menu - it covers most of it.
Just a few interesting links to help building and debugging RegEx.
Here is a link to RegEx documentation:
perlre - perldoc.perl.org[^]
Here is links to tools to help build RegEx and debug them:
.NET Regex Tester - Regex Storm[^]
Expresso Regular Expression Tool[^]
RegExr: Learn, Build, & Test RegEx[^]
Online regex tester and debugger: PHP, PCRE, Python, Golang and JavaScript[^]
This one show you the RegEx as a nice graph which is really helpful to understand what is doing a RegEx: Debuggex: Online visual regex tester. JavaScript, Python, and PCRE.[^]
This site also show the Regex in a nice graph but can't test what match the RegEx: Regexper[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900