c# - Grab Value In String -


i have list of browser agent strings each string looking -

mozilla/5.0 (ipad; cpu os 6_1 mac os x)
applewebkit/536.26 (khtml, gecko) version/6.0
mobile/10b141
safari/8536.25

using foreach loop going through list of these strings. on each iteration want extract os version out i'm assigning variable before proceed process further.

foreach (var e in agentstrings) {    var myos = e.useragent os  (6_1_3) ??     // more stuff here } 

what's easiest way retrieve value between os , in agent string?

probably best way check see if string contains short list of os's you're looking for:

string theos = ""; var agentstring = e.useragent; if(agentstring.contains("mac os x")     theos = "mac os x"; else if(agentstring.contains("windows 8")     theos = "windows 8"; 

etc.

that's how msdn , other stack overflow questions seem recommend doing


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -