-1

I am try to generate a proper pattern. But I couldn't find it.

http://www.sporx.com/tvdebugun/ in this site. i try to capture enter image description here

I am using c#. I just created this pattern to capture each lists information's.

string pattern =@"<li class="(odd|even)">(.*)<span class="ch-type">(.*)<\/span>(.*)<span class="ch-time">(.*)<\/span>(.*)<div class="ch-desc">(.*)<span class="ch-name">(.*)<\/span>(.*)<span class="ch-text">(.*)<\/span>(.*)<\/div><\/li>"

thanks.

Jim
  • 2,974
  • 2
  • 19
  • 29
Ozan Ertürk
  • 465
  • 5
  • 17
  • 5
    Some people always say: don't parse html with regex. [Using regular expressions to parse HTML: why not?](http://stackoverflow.com/questions/590747/using-regular-expressions-to-parse-html-why-not) **You could try something like [htmlagilitypack](http://htmlagilitypack.codeplex.com/)** – Jeroen van Langen Nov 09 '16 at 15:25
  • Are you using `(.*)` in case there are newlines or spaces? I thought `\s*` would work there and be more reliable – Alfie Goodacre Nov 09 '16 at 15:27
  • do you have any different approach for this situation – Ozan Ertürk Nov 09 '16 at 15:27
  • @AlfieGoodacre i replace new lines to emty strings – Ozan Ertürk Nov 09 '16 at 15:27
  • Use html parser it is cleaner and faster and correct. If you can tell the exact logic I can write you what you need. – mybirthname Nov 09 '16 at 15:28
  • Where is the source code? Show us what you want to accomplish before, and after. – Ibrahim Nov 09 '16 at 15:29
  • @mybirthname ah so thanks. as the image above , i am try to get each list items information that marked with numbers. – Ozan Ertürk Nov 09 '16 at 15:29
  • 2
    Show the html code and tell us what you need to take from this html, I can't see html from pictures – mybirthname Nov 09 '16 at 15:30
  • Please read [ask]. Key phrases: "Search, and research" and "Explain ... any difficulties that have prevented you from solving it yourself". – Heretic Monkey Nov 09 '16 at 15:35
  • @mybirthname https://jsfiddle.net/2dzzfmpa/ here is an example. i wrote coment line with number that shows where i want to capture. between the tags – Ozan Ertürk Nov 09 '16 at 15:37

1 Answers1

1

Try this code:

(?<=(ch-name">)|(?<=ch-time">)|(?<=ch-type">)|(?<=ch-text">))[\s\S]*?(?=<\/)

Demo: https://regex101.com/r/d8PJa9/2

Ibrahim
  • 6,006
  • 3
  • 39
  • 50