c# - Regex from a html parsing, how do I grab a specific string? -


i'm trying string after charactername= , before " >. how use regex allow me catch player name?

this have far, , it's not working. not working doesn't print anything. on client.downloadstring returns string this:

<a href="https://my.examplegame.com/charactername=atro+roter" >

so, know gets string, i'm stuck on regex.

using (var client = new webclient())         {              //example of string looks on console when console.writeline(html)             //<a href="https://my.examplegame.com/charactername=atro+roter" >              // want "atro+roter"              string html = client.downloadstring(worlddest + world + inordername);             string playername = "https://my.examplegame.com/charactername=(.+?)\" >";              matchcollection m1 = regex.matches(html, playername);               foreach (match m in m1)             {                 console.writeline(m.groups[1].value);             }         } 

i'm trying string after charactername= , before " >. 

so, need lookbehind lookahead , use linq match values list:

var input = "your input string"; var rx = new regex(@"(?<=charactername=)[^""]+(?="")"; var res = rx.matches(input).cast<match>().select(p => p.value).tolist(); 

the res variable should hold character names now.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -