Click here to Skip to main content
15,897,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi!

I'm wondering what would be the best and easyest way to extract "Sondrey", "Twitch" and "3" from this string:

Spawning champion (Twitch) with skinID 3 on team 100 for clientID 0 and summonername (Sondrey) (is HUMAN PLAYER)

both where it says "Twitch" and where it says "sondrey" is valiables and might change to names with spaces. So using Split would be unreliable. i allso needs to store the values in a string, so i can use them later.

the summonername might include spaces
the champion name might inclute spaces and dots ('.')
The skin ID runs from 0 to something like.. 7~ at the most

Thanks!
Posted

1 solution

If the text is regular enough, you should try Regular Expressions.

http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx[^]


RegexTester[^]

http://www.ultrapico.com/Expresso.htm[^]

Something like this might work for a start:
\((?'Name'[^)]*)\).*?skinID (?'SkinID'\d+).*?\((?'Summoner'[^)]*)\)
 
Share this answer
 
v3
Comments
Member 7889603 26-Jul-14 12:56pm    
This works perfectly for what i wanted! Thanks a lot! I've seen people use Regex around before, but it's one of the things i've never got time to check out myself. But as i see now, it looks like a very powerfull tool. Don't really understand how it works tho, All the symbols makes little sence to me, i see that you store the values as; Name, SkinID and Summoner, but the rest is kinda confusing ^^" guess i'll have to read my wayup on this.

Again, thanks a lot!

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