0

I need to get this regex to work but cant figure it out.

<li name="random" class="random" id="random" value="random">random</li>
<li name="random" class="random" id="random" value="random">random</li>
<li name="random" class="random" id="random" value="random">Föredrar att inte uppge</li>

Random means random data and I want just the last tag data and it can be diffrent amount of tags aswell so every thing between the last "<li" and "Föredrar att inte uppge"

Thus Spoke Nomad
  • 2,372
  • 4
  • 17
  • 34
  • is your issue with the regex expression or the code or both? – 2c2c Jul 18 '15 at 03:29
  • just the regex i cant get the data from the li tag i just get the evrything from the first
  • to Föredrar att inte uppge, just the regex expression
  • – user3050767 Jul 18 '15 at 03:33
  • can the adjacent tags have anything between them? if so you can do a search between '>' and '<' – 2c2c Jul 18 '15 at 03:43
  • all the tags has random data except for the last string i put in and that the text in the li tag – user3050767 Jul 18 '15 at 03:45
  • Do I understand this right ... you need the data "name="random" class="random" id="random" value="random"" only from the last li tag in the above example – sundeep Jul 18 '15 at 03:48
  • I misunderstood what you wanted I think. you should probably give full input/output – 2c2c Jul 18 '15 at 03:50
  • @sundeep yes like you wrote and its allways the last one i can get the data out no problem i just need a way to select the last one – user3050767 Jul 18 '15 at 03:57
  • @user3050767 You could select the last line using ^.*(?![\f\n\r])$ If this line will always have the string "Föredrar att inte uppge" you could also use the regex '
  • Föredrar att inte uppge' and then match the first group from it
  • – sundeep Jul 18 '15 at 04:06
  • Use [htmlagilitypack](https://htmlagilitypack.codeplex.com/). – EZI Jul 18 '15 at 04:08